X-Git-Url: https://git.lyx.org/gitweb/?a=blobdiff_plain;f=lib%2Fexamples%2Fsweave.lyx;h=e11bcf9fef2771b9ad40ee4f70bd7358c508032e;hb=3fd0cc27d47d79513487e56a254c90e1794b6b0e;hp=59d64dfeefa58cfebffcbabdab086c9fec4be0f5;hpb=425c190d623daeb6d05bce1aa2244b548225305a;p=lyx.git diff --git a/lib/examples/sweave.lyx b/lib/examples/sweave.lyx index 59d64dfeef..e11bcf9fef 100644 --- a/lib/examples/sweave.lyx +++ b/lib/examples/sweave.lyx @@ -1,5 +1,5 @@ #LyX 2.3 created this file. For more info see http://www.lyx.org/ -\lyxformat 508 +\lyxformat 544 \begin_document \begin_header \save_transient_properties true @@ -36,6 +36,8 @@ sweave \font_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 @@ -48,23 +50,24 @@ sweave \use_geometry true \use_package amsmath 1 \use_package amssymb 1 -\use_package cancel 0 +\use_package cancel 1 \use_package esint 1 \use_package mathdots 1 -\use_package mathtools 0 +\use_package mathtools 1 \use_package mhchem 1 -\use_package stackrel 0 -\use_package stmaryrd 0 -\use_package undertilde 0 +\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 +\suppress_date true \justification true \use_refstyle 0 +\use_minted 0 \index Index \shortcut idx \color #008000 @@ -77,36 +80,32 @@ sweave \tocdepth 3 \paragraph_separation indent \paragraph_indentation default -\quotes_language english +\is_math_indent 0 +\math_numbering_side default +\quotes_style english +\dynamic_quotes 0 \papercolumns 1 \papersides 1 \paperpagestyle default -\tracking_changes true +\tracking_changes false \output_changes false \html_math_output 0 \html_css_as_file 0 \html_be_strict false -\author 2047637253 "Guillaume Munch" \end_header \begin_body \begin_layout Standard - -\change_inserted 2047637253 1483897614 \begin_inset Note Note status open \begin_layout Plain Layout - -\change_inserted 2047637253 1483897614 \begin_inset Flex Sweave Options status open \begin_layout Plain Layout -\change_inserted 2047637253 1483897614 - prefix=TRUE,prefix.string=sweave-prefix,keep.source=FALSE \end_layout @@ -118,8 +117,6 @@ prefix=TRUE,prefix.string=sweave-prefix,keep.source=FALSE \end_inset -\change_unchanged - \end_layout \begin_layout Standard @@ -165,6 +162,7 @@ LatexCommand href name "xie@yihui.name" target "xie@yihui.name" type "mailto:" +literal "false" \end_inset @@ -255,13 +253,9 @@ https://github.com/downloads/yihui/lyx/sweave.pdf \end_inset . -\change_inserted 2047637253 1483898587 - \end_layout \begin_layout Standard - -\change_inserted 2047637253 1483899123 Since \SpecialChar LyX 2.3, it is necessary to enable the use of \emph on @@ -274,8 +268,6 @@ File Handling\SpecialChar menuseparator Converters \family default in order to compile with Sweave. -\change_unchanged - \end_layout \begin_layout Section @@ -343,21 +335,16 @@ bin \end_layout \begin_layout Standard - -\change_inserted 2047637253 1483897627 \begin_inset Flex Chunk status open \begin_layout Plain Layout -\change_inserted 2047637253 1483897627 - \begin_inset Argument 1 status open \begin_layout Plain Layout -\change_inserted 2047637253 1483897627 where-is-R-bin,eval=FALSE \end_layout @@ -368,16 +355,12 @@ where-is-R-bin,eval=FALSE \begin_layout Plain Layout -\change_inserted 2047637253 1483897627 - R.home('bin') \end_layout \end_inset -\change_unchanged - \end_layout \begin_layout Standard @@ -412,21 +395,16 @@ Sweave.sty \end_layout \begin_layout Standard - -\change_inserted 2047637253 1483897639 \begin_inset Flex Chunk status open \begin_layout Plain Layout -\change_inserted 2047637253 1483897639 - \begin_inset Argument 1 status open \begin_layout Plain Layout -\change_inserted 2047637253 1483897639 sweave-sty,eval=FALSE \end_layout @@ -437,16 +415,12 @@ sweave-sty,eval=FALSE \begin_layout Plain Layout -\change_inserted 2047637253 1483897639 - file.path(R.home('share'), 'texmf', 'tex', 'latex') \end_layout \end_inset -\change_unchanged - \end_layout \begin_layout Standard @@ -520,37 +494,20 @@ echo=FALSE \begin_layout Standard To write R code in \SpecialChar LyX -, you can first -\change_inserted 2047637253 1483898412 -insert -\change_deleted 2047637253 1483898419 -switch to the -\change_unchanged - +, you can first insert \family typewriter Chunk \family default - -\change_inserted 2047637253 1483898437 -insets from + insets from \family sans Insert\SpecialChar menuseparator Custom Insets\SpecialChar menuseparator Chunk -\change_deleted 2047637253 1483898459 - \family default -environment in the layout styles list (droplist in the top-left corner in - the toolbar) -\change_unchanged , or you can simply open a \SpecialChar TeX code environment and write Sweave code chunks in it. - -\change_deleted 2047637253 1483898024 -The latter approach is recommended since it is more stable. -\change_inserted 2047637253 1483961753 -However, \SpecialChar LyX + However, \SpecialChar LyX provides a summary of all the \family typewriter Chunk @@ -566,8 +523,6 @@ View\SpecialChar menuseparator Outline Pane \family default menus. -\change_unchanged - \end_layout \begin_layout Standard @@ -587,21 +542,16 @@ useFancyQuotes \end_layout \begin_layout Standard - -\change_inserted 2047637253 1483897653 \begin_inset Flex Chunk status open \begin_layout Plain Layout -\change_inserted 2047637253 1483897653 - \begin_inset Argument 1 status open \begin_layout Plain Layout -\change_inserted 2047637253 1483897653 setup, keep.source=TRUE \end_layout @@ -612,15 +562,11 @@ setup, keep.source=TRUE \begin_layout Plain Layout -\change_inserted 2047637253 1483897653 - ## the option 'digits' can set the (approximate) number of digits \end_layout \begin_layout Plain Layout -\change_inserted 2047637253 1483897653 - options(width = 70, useFancyQuotes = FALSE, digits = 4) \end_layout @@ -630,21 +576,16 @@ options(width = 70, useFancyQuotes = FALSE, digits = 4) \end_layout \begin_layout Standard - -\change_inserted 2047637253 1483897653 \begin_inset Flex Chunk status open \begin_layout Plain Layout -\change_inserted 2047637253 1483897653 - \begin_inset Argument 1 status open \begin_layout Plain Layout -\change_inserted 2047637253 1483897653 sweave-manual, eval=FALSE, keep.source=TRUE \end_layout @@ -655,23 +596,17 @@ sweave-manual, eval=FALSE, keep.source=TRUE \begin_layout Plain Layout -\change_inserted 2047637253 1483897653 - ## view the Sweave vignette (requires R >= 2.13.0) \end_layout \begin_layout Plain Layout -\change_inserted 2047637253 1483897653 - vignette("Sweave", package = "utils") \end_layout \end_inset -\change_unchanged - \end_layout \begin_layout Standard @@ -679,21 +614,16 @@ A simple example that will run in any S engine: \end_layout \begin_layout Standard - -\change_inserted 2047637253 1483897659 \begin_inset Flex Chunk status open \begin_layout Plain Layout -\change_inserted 2047637253 1483897659 - \begin_inset Argument 1 status open \begin_layout Plain Layout -\change_inserted 2047637253 1483897659 print-integers, keep.source=TRUE \end_layout @@ -704,15 +634,11 @@ print-integers, keep.source=TRUE \begin_layout Plain Layout -\change_inserted 2047637253 1483897659 - ## the integers from 1 to 10 are \end_layout \begin_layout Plain Layout -\change_inserted 2047637253 1483897659 - 1:10 \end_layout @@ -722,21 +648,16 @@ print-integers, keep.source=TRUE \end_layout \begin_layout Standard - -\change_inserted 2047637253 1483897659 \begin_inset Flex Chunk status open \begin_layout Plain Layout -\change_inserted 2047637253 1483897659 - \begin_inset Argument 1 status open \begin_layout Plain Layout -\change_inserted 2047637253 1483897659 hide-results, results=hide \end_layout @@ -747,23 +668,17 @@ hide-results, results=hide \begin_layout Plain Layout -\change_inserted 2047637253 1483897659 - ## intentionally hide the output by setting results=hide \end_layout \begin_layout Plain Layout -\change_inserted 2047637253 1483897659 - print(1:20) \end_layout \end_inset -\change_unchanged - \end_layout \begin_layout Standard @@ -771,21 +686,16 @@ We can also emulate a simple calculator: \end_layout \begin_layout Standard - -\change_inserted 2047637253 1483897665 \begin_inset Flex Chunk status open \begin_layout Plain Layout -\change_inserted 2047637253 1483897665 - \begin_inset Argument 1 status open \begin_layout Plain Layout -\change_inserted 2047637253 1483897665 calculator \end_layout @@ -796,23 +706,17 @@ calculator \begin_layout Plain Layout -\change_inserted 2047637253 1483897665 - 1 + pi \end_layout \begin_layout Plain Layout -\change_inserted 2047637253 1483897665 - sin(pi/6) \end_layout \end_inset -\change_unchanged - \end_layout \begin_layout Standard @@ -820,21 +724,16 @@ Now we look at some Gaussian data: \end_layout \begin_layout Standard - -\change_inserted 2047637253 1483897670 \begin_inset Flex Chunk status open \begin_layout Plain Layout -\change_inserted 2047637253 1483897670 - \begin_inset Argument 1 status open \begin_layout Plain Layout -\change_inserted 2047637253 1483897670 rnorm \end_layout @@ -845,37 +744,27 @@ rnorm \begin_layout Plain Layout -\change_inserted 2047637253 1483897670 - set.seed(123) # for reproducibility \end_layout \begin_layout Plain Layout -\change_inserted 2047637253 1483897670 - x <- rnorm(20) \end_layout \begin_layout Plain Layout -\change_inserted 2047637253 1483897670 - print(x) \end_layout \begin_layout Plain Layout -\change_inserted 2047637253 1483897670 - t1 <- t.test(x) \end_layout \end_inset -\change_unchanged - \end_layout \begin_layout Standard @@ -971,21 +860,16 @@ iris \end_layout \begin_layout Standard - -\change_inserted 2047637253 1483897677 \begin_inset Flex Chunk status open \begin_layout Plain Layout -\change_inserted 2047637253 1483897677 - \begin_inset Argument 1 status open \begin_layout Plain Layout -\change_inserted 2047637253 1483897677 iris-summary \end_layout @@ -996,16 +880,12 @@ iris-summary \begin_layout Plain Layout -\change_inserted 2047637253 1483897677 - summary(iris[,-5]) \end_layout \end_inset -\change_unchanged - \end_layout \begin_layout Standard @@ -1035,24 +915,17 @@ name "tab:xtable-demo" \end_inset -\change_inserted 2047637253 1483897685 - \begin_inset Flex Chunk status open \begin_layout Plain Layout -\change_inserted 2047637253 1483897698 - \begin_inset Argument 1 status open \begin_layout Plain Layout -\change_inserted 2047637253 1483897692 xtable-demo,results=tex,echo=FALSE -\change_unchanged - \end_layout \end_inset @@ -1062,33 +935,23 @@ xtable-demo,results=tex,echo=FALSE \begin_layout Plain Layout -\change_inserted 2047637253 1483897699 - if (require('xtable')) { \end_layout \begin_layout Plain Layout -\change_inserted 2047637253 1483897699 - print(xtable(sapply(iris[,-5], quantile)), floating=FALSE) \end_layout \begin_layout Plain Layout -\change_inserted 2047637253 1483897699 - } else cat('the xtable package is not available! please install.packages("xtable" )') -\change_unchanged - \end_layout \end_inset -\change_unchanged - \end_layout \end_inset @@ -1175,24 +1038,17 @@ Both eps and pdf are set to true so that both latex and pdflatex work. \begin_layout Plain Layout \align center - -\change_inserted 2047637253 1483897765 \begin_inset Flex Chunk status open \begin_layout Plain Layout -\change_inserted 2047637253 1483897772 - \begin_inset Argument 1 status open \begin_layout Plain Layout -\change_inserted 2047637253 1483897770 iris-pairs,fig=TRUE,width=4.5,height=4.5,eps=TRUE,pdf=TRUE -\change_unchanged - \end_layout \end_inset @@ -1202,18 +1058,12 @@ iris-pairs,fig=TRUE,width=4.5,height=4.5,eps=TRUE,pdf=TRUE \begin_layout Plain Layout -\change_inserted 2047637253 1483897776 - pairs(iris, col = iris$Species) -\change_unchanged - \end_layout \end_inset -\change_unchanged - \end_layout \begin_layout Plain Layout @@ -1252,21 +1102,16 @@ status open \begin_layout Plain Layout \align center - -\change_inserted 2047637253 1483897883 \begin_inset Flex Chunk status open \begin_layout Plain Layout -\change_inserted 2047637253 1483897883 - \begin_inset Argument 1 status open \begin_layout Plain Layout -\change_inserted 2047637253 1483897883 iris-boxplots,fig=TRUE,width=7,height=2,keep.source=F,eps=T,pdf=T \end_layout @@ -1277,23 +1122,17 @@ iris-boxplots,fig=TRUE,width=7,height=2,keep.source=F,eps=T,pdf=T \begin_layout Plain Layout -\change_inserted 2047637253 1483897883 - par(mar=c(4,5,.1,.3), las=1) \end_layout \begin_layout Plain Layout -\change_inserted 2047637253 1483897883 - boxplot(Sepal.Length~Species,data=iris,horizontal=TRUE,xlab='Sepal.Length') \end_layout \end_inset -\change_unchanged - \end_layout \begin_layout Plain Layout @@ -1333,8 +1172,6 @@ R/S code R CMD Stangle \family default . -\change_inserted 2047637253 1483898877 - \end_layout \begin_layout Section @@ -1507,7 +1344,8 @@ Sweave will use the filename of the Rnw file as the prefix string for the \begin_inset CommandInset href LatexCommand href name "#7551" -target "http://www.lyx.org/trac/ticket/7551" +target "https://www.lyx.org/trac/ticket/7551" +literal "false" \end_inset @@ -1694,17 +1532,9 @@ label= \end_layout \begin_layout Standard -Another -\change_deleted 2047637253 1483899012 -known -\change_unchanged - issue -\change_inserted 2047637253 1483898966 -with the \SpecialChar TeX - code environment -\change_unchanged -is the Sweave code chunk may fail when we change the alignment of the chunk - paragraph in \SpecialChar LyX +Another issue with the \SpecialChar TeX + code environment is the Sweave code chunk may fail + when we change the alignment of the chunk paragraph in \SpecialChar LyX (using \family sans Paragraph settings @@ -1756,36 +1586,10 @@ This is not a legitimate Sweave code chunk, since <<>>= \family default must start in a new line with nothing before it. - -\change_inserted 2047637253 1483899083 This does not happen when using the Chunk inset instead of the \SpecialChar TeX code environmen t. - -\change_unchanged -\change_deleted 2047637253 1483898988 -Therefore we recommend you to double check the real source code via -\family sans -View\SpecialChar menuseparator -View Source -\family default - when changing the alignment of a chunk paragraph, and make sure -\family typewriter -<<>>= -\family default - appears in a new line. - This explains why we manually added an empty line in the code chunk in - Table -\begin_inset CommandInset ref -LatexCommand ref -reference "tab:xtable-demo" - -\end_inset - -. -\change_unchanged - \end_layout \begin_layout Section @@ -1793,13 +1597,13 @@ Resources \end_layout \begin_layout Standard -The homepage of Sweave is at +The user manual of Sweave is at \begin_inset Flex URL status collapsed \begin_layout Plain Layout -http://www.stat.uni-muenchen.de/~leisch/Sweave/ +https://stat.ethz.ch/R-manual/R-devel/library/utils/doc/Sweave.pdf \end_layout \end_inset @@ -1834,7 +1638,7 @@ status collapsed \begin_layout Plain Layout -http://www.lyx.org/MailingLists +https://www.lyx.org/MailingLists \end_layout \end_inset