#LyX 2.4 created this file. For more info see https://www.lyx.org/ \lyxformat 620 \begin_document \begin_header \save_transient_properties true \origin /systemlyxdir/examples/Modules/ \textclass article \use_default_options true \begin_modules knitr \end_modules \maintain_unincluded_children no \language english \language_package default \inputencoding utf8 \fontencoding auto \font_roman "palatino" "default" \font_sans "lmss" "default" \font_typewriter "lmtt" "default" \font_math "auto" "auto" \font_default_family default \use_non_tex_fonts false \font_sc false \font_roman_osf false \font_sans_osf false \font_typewriter_osf false \font_sf_scale 100 100 \font_tt_scale 100 100 \use_microtype false \use_dash_ligatures false \graphics default \default_output_format default \output_sync 0 \bibtex_command default \index_command default \paperfontsize default \spacing single \use_hyperref false \papersize default \use_geometry true \use_package amsmath 1 \use_package amssymb 1 \use_package cancel 1 \use_package esint 1 \use_package mathdots 1 \use_package mathtools 1 \use_package mhchem 1 \use_package stackrel 1 \use_package stmaryrd 1 \use_package undertilde 1 \cite_engine basic \cite_engine_type default \biblio_style plain \use_bibtopic false \use_indices false \paperorientation portrait \suppress_date false \justification true \use_refstyle 1 \use_minted 0 \use_lineno 0 \index Index \shortcut idx \color #008000 \end_index \leftmargin 2.5cm \topmargin 2.5cm \rightmargin 2.5cm \bottommargin 2.5cm \secnumdepth 3 \tocdepth 3 \paragraph_separation indent \paragraph_indentation default \is_math_indent 0 \math_numbering_side default \quotes_style english \dynamic_quotes 0 \papercolumns 1 \papersides 1 \paperpagestyle default \tablestyle default \tracking_changes false \output_changes false \change_bars false \postpone_fragile_content false \html_math_output 0 \html_css_as_file 0 \html_be_strict false \docbook_table_output 0 \docbook_mathml_prefix 1 \end_header \begin_body \begin_layout Title Using knitr with \SpecialChar LyX \end_layout \begin_layout Author Yihui Xie \begin_inset Foot status collapsed \begin_layout Plain Layout Department of Statistics, Iowa State University. Email: \begin_inset CommandInset href LatexCommand href name "xie@yihui.name" target "xie@yihui.name" type "mailto:" literal "false" \end_inset \end_layout \end_inset \end_layout \begin_layout Standard The R ( \begin_inset Flex URL status collapsed \begin_layout Plain Layout http://www.r-project.org \end_layout \end_inset ) package \series bold knitr \series default is an alternative tool to Sweave based on a different design with more features. \SpecialChar LyX has native support to Sweave since version 2.0.0, and the support to \series bold knitr \series default was also added since 2.0.3. The usage is basically the same as the \family sans Sweave \family default module \begin_inset Foot status open \begin_layout Plain Layout read the \SpecialChar LyX /Sweave manual from \family sans Help\SpecialChar menuseparator Specific Manuals \end_layout \end_inset : \end_layout \begin_layout Enumerate Open a new \SpecialChar LyX document; \end_layout \begin_layout Enumerate Go to \family sans Document\SpecialChar menuseparator Settings\SpecialChar menuseparator Modules \family default and insert the module named \family sans Rnw (knitr) \family default ; \end_layout \begin_layout Enumerate Then insert R code in the document with either \family sans Insert\SpecialChar menuseparator \SpecialChar TeX Code \family default or the \family sans Chunk \family default environment; \end_layout \begin_layout Standard The package website \begin_inset Flex URL status collapsed \begin_layout Plain Layout http://yihui.name/knitr \end_layout \end_inset has full documentation and demos of \series bold knitr \series default ; many of the examples have links to the \SpecialChar LyX source documents. \end_layout \begin_layout Standard Since \SpecialChar LyX 2.3, it is necessary to enable the use of \emph on needauth \emph default converters in \family sans Preferences\SpecialChar menuseparator File Handling\SpecialChar menuseparator Converters \family default in order to compile with \series bold knitr \series default . \end_layout \begin_layout Standard Note the \series bold knitr \series default package requires R >= 2.14.1, so you need to update R if you are using an old version of R. Here we show one chunk as a simple example: \end_layout \begin_layout Standard \begin_inset Flex Chunk status open \begin_layout Plain Layout \begin_inset Argument 1 status open \begin_layout Plain Layout show-off \end_layout \end_inset \end_layout \begin_layout Plain Layout rnorm(5) \end_layout \begin_layout Plain Layout df=data.frame(y=rnorm(100), x=1:100) \end_layout \begin_layout Plain Layout summary(lm(y~x, data=df)) \end_layout \end_inset \end_layout \begin_layout Standard Please contact the package author in case of any problems. \end_layout \end_body \end_document