Re: [R] Knitr: setting echo = FALSE globally [RESOLVED]
On Tue, 21 Jul 2015, John Kane wrote: It sounds like your approach with the chunks is equivalent to my approach. Somewhere I remember reading that the global chunk commands apply to everything 'after' the global command--which once one thinks about it is sensible . John, Yes, it makes sense. So it should work if echo=FALSE is in a chunk _or_ in the ERT box. Needing to be in both is not expected. Glad it's working. R +knitr does save a lot of time once you get it working. I'm looking forward to that time savings. :-) Many thanks, Rich __ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Knitr: setting echo = FALSE globally [RESOLVED]
Hi Rich, It sounds like your approach with the chunks is equivalent to my approach. Somewhere I remember reading that the global chunk commands apply to everything 'after' the global command--which once one thinks about it is sensible . Glad it's working. R +knitr does save a lot of time once you get it working. John Kane Kingston ON Canada > -Original Message- > From: rshep...@appl-ecosys.com > Sent: Tue, 21 Jul 2015 08:30:09 -0700 (PDT) > To: r-help@r-project.org > Subject: Re: [R] Knitr: setting echo = FALSE globally [RESOLVED] > > On Mon, 20 Jul 2015, John Kane wrote: > >> I have no idea wha that chunk is not working but I think you can get the >> same result using the old method Stick the following in an ERT box: >> >> <>= >> opts_chunk$set(echo = FALSE) >> @ > > John, > >My original response was too large (3 attached PDF files) and was held > for > moderator approval which is no longer needed. > >I found the magic solution; looks awkward, but it works. > >Near the top of the document (well before any R code) I insert a knitr > chunk containing the directive, opts_chunk$set(echo=FALSE). This is > immediately followed by an ERT box as above. The double whammy prevents R > code from echoing ... except for the contents of the leading chunk > itself. > >Adding the option, echo=FALSE, to that leading chunk prevents it from > displaying. > >Note that both the chunk with opts_chunk$set() and the ERT is required > to > prevent R code from displaying. No chunk but ERT box does not stop the > echoing. > > Thanks for the pointer, > > Rich > > __ > R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide > http://www.R-project.org/posting-guide.html > and provide commented, minimal, self-contained, reproducible code. Publish your photos in seconds for FREE TRY IM TOOLPACK at http://www.imtoolpack.com/default.aspx?rc=if4 __ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Knitr: setting echo = FALSE globally [RESOLVED]
On Mon, 20 Jul 2015, John Kane wrote: I have no idea wha that chunk is not working but I think you can get the same result using the old method Stick the following in an ERT box: <>= opts_chunk$set(echo = FALSE) @ John, My original response was too large (3 attached PDF files) and was held for moderator approval which is no longer needed. I found the magic solution; looks awkward, but it works. Near the top of the document (well before any R code) I insert a knitr chunk containing the directive, opts_chunk$set(echo=FALSE). This is immediately followed by an ERT box as above. The double whammy prevents R code from echoing ... except for the contents of the leading chunk itself. Adding the option, echo=FALSE, to that leading chunk prevents it from displaying. Note that both the chunk with opts_chunk$set() and the ERT is required to prevent R code from displaying. No chunk but ERT box does not stop the echoing. Thanks for the pointer, Rich __ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Knitr: setting echo = FALSE globally
Hi Rich, I have no idea wha that chunk is not working but I think you can get the same result using the old method Stick the following in an ERT (Insert > Tex Code) <>= opts_chunk$set(echo = FALSE) @ Heck, I've only been using LyX for 4-5 years and already I'm sounding crotchety. John Kane Kingston ON Canada > -Original Message- > From: rshep...@appl-ecosys.com > Sent: Mon, 20 Jul 2015 12:58:51 -0700 (PDT) > To: r-help@r-project.org > Subject: Re: [R] Knitr: setting echo = FALSE globally > > On Mon, 20 Jul 2015, Thierry Onkelinx wrote: > >> We need the source file. > >Attached to the original message was the TeX output called, > 'sample.txt'. > I've attached it again, but with the .tex extension. Also, the .lyx file > is > attached. > > Rich > __ > R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide > http://www.R-project.org/posting-guide.html > and provide commented, minimal, self-contained, reproducible code. FREE 3D MARINE AQUARIUM SCREENSAVER - Watch dolphins, sharks & orcas on your desktop! __ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Knitr: setting echo = FALSE globally
On Mon, 20 Jul 2015, Thierry Onkelinx wrote: We need the source file. Attached to the original message was the TeX output called, 'sample.txt'. I've attached it again, but with the .tex extension. Also, the .lyx file is attached. Rich#LyX 2.1 created this file. For more info see http://www.lyx.org/ \lyxformat 474 \begin_document \begin_header \textclass scrreprt \begin_preamble \date{} \usepackage{textcomp,url,multicol} %\setkomafont{sectioning}{\rmfamily} \end_preamble \options abstract=on \use_default_options false \begin_modules natbibapa knitr \end_modules \maintain_unincluded_children false \language english \language_package default \inputencoding auto \fontencoding global \font_roman palatino \font_sans default \font_typewriter default \font_math auto \font_default_family default \use_non_tex_fonts false \font_sc false \font_osf false \font_sf_scale 100 \font_tt_scale 100 \graphics default \default_output_format default \output_sync 0 \bibtex_command bibtex \index_command default \paperfontsize default \spacing single \use_hyperref false \papersize letterpaper \use_geometry false \use_package amsmath 1 \use_package amssymb 1 \use_package cancel 1 \use_package esint 0 \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 natbib \cite_engine_type authoryear \biblio_style humannat \use_bibtopic false \use_indices false \paperorientation portrait \suppress_date false \justification true \use_refstyle 0 \index Index \shortcut idx \color #008000 \end_index \secnumdepth 2 \tocdepth 2 \paragraph_separation indent \paragraph_indentation default \quotes_language english \papercolumns 1 \papersides 2 \paperpagestyle default \tracking_changes false \output_changes false \html_math_output 0 \html_css_as_file 0 \html_be_strict false \end_header \begin_body \begin_layout Standard In 1986 Ward described the status of water quality assessment as "data rich and information poor" \begin_inset CommandInset citation LatexCommand citep key "Ward1986" \end_inset . The authors addressed the lack of science-based design of monitoring location networks; this situation still applies. They defined water quality monitoring as "any effort by a government or private enterprise to obtain an understanding of the physical, chemical, and biological characteristics of water via statistical sampling." Of course, their definition also applies to appropriate statistical analyses of the collected data. \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 opts_chunk$set(echo = FALSE) \end_layout \end_inset \end_layout \end_inset \end_layout \begin_layout Standard \begin_inset Flex Chunk status collapsed \begin_layout Plain Layout load('.RData') \begin_inset Argument 1 status collapsed \begin_layout Plain Layout tidy=T, tidy.opts=list(width.cutoff=60) \end_layout \end_inset \end_layout \end_inset \end_layout \begin_layout Standard The data available for the Carlin site (USGS station number 10321000 are in Appendix A. Many documents on data analysis and statistics use small sample sets to illustrate the points the author wants the reader to learn. Real-world environmental data sets frequently are very large so this document uses 52 variables from the total available from the USGS's web site. \end_layout \begin_layout Standard The first step in analyzing water chemistry data for CWA compliance is reading it into the analytical software and converting column data types as necessary. \end_layout \begin_layout Standard \begin_inset Flex Chunk status collapsed \begin_layout Plain Layout carlin <- read.csv("./carlin.csv", header=T, sep=",", stringsAsFactors=F) \end_layout \begin_layout Plain Layout carlin$sampdate <- as.Date(carlin$sampdate) \begin_inset Argument 1 status open \begin_layout Plain Layout 'input_data' \end_layout \end_inset \end_layout \end_inset \end_layout \begin_layout Standard Next, check that the data are what you expect to see and convert dates from factors. The site ID number is retained for use when examining multiple stations along the Humboldt River for longitudinal changes and other variables that might affect the measured values. \end_layout \begin_layout Standard \begin_inset Flex Chunk status collapsed \begin_layout Plain Layout \begin_inset Argument 1 status collapsed \begin_layout Plain Layout 'data_set_structure' \end_layout \end_inset str(carlin, width=60, strict.width='cut') \end_layout \end_inset \end_layout \end_body \end_document __ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Knitr: setting echo = FALSE globally
On Mon, 20 Jul 2015, Yihui Xie wrote: Section 5.1.3 of the book "Dynamic Documents with R and knitr" is titled "Global Options". I don't know how to make it more clear for readers to find information on global options in the book. Yes, I've read that and have not found where 'opts_chunk$set(echo = FALSE)' should be inserted in the document. If I put it in the first chunk, outside the options box, pdflatex throws an error. If it is in it's own chunk, either by itself or in the options box, there's the same verbose error when trying to compile it. When I put it in the body of the document it's printed as is. Where should that command be entered in the document? Rich __ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Knitr: setting echo = FALSE globally
We need the source file. Not the output. And please try to make it as small as possible while still reproducing the problem. The smaller the example, the easier it is for us to help you. Op 20-jul.-2015 21:17 schreef "Rich Shepard" : > On Mon, 20 Jul 2015, Thierry Onkelinx wrote: > > Have you tried echo = FALSE instead of echo = F. If that doesn't solve >> your problem, please provide a minimal reproducible example. >> > > Yes, I have. > > Attached is a TeX file renamed to sample.txt (rather than .tex to ensure > it is not stripped), a PDF of the compiled page, and the source data that's > being read in the sample doc. > > Thanks, > > Rich > > __ > R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide > http://www.R-project.org/posting-guide.html > and provide commented, minimal, self-contained, reproducible code. > [[alternative HTML version deleted]] __ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Knitr: setting echo = FALSE globally
On Mon, 20 Jul 2015, Thierry Onkelinx wrote: Have you tried echo = FALSE instead of echo = F. If that doesn't solve your problem, please provide a minimal reproducible example. Yes, I have. Attached is a TeX file renamed to sample.txt (rather than .tex to ensure it is not stripped), a PDF of the compiled page, and the source data that's being read in the sample doc. Thanks, Rich \batchmode \makeatletter \def\input@path{{/home/rshepard/documents/white-papers/water-chem-anal//}} \makeatother \documentclass[letterpaper,twoside,english,abstract=on]{scrreprt}\usepackage[]{graphicx}\usepackage[]{color} %% maxwidth is the original width if it is less than linewidth %% otherwise use linewidth (to make sure the graphics do not exceed the margin) \makeatletter \def\maxwidth{ % \ifdim\Gin@nat@width>\linewidth \linewidth \else \Gin@nat@width \fi } \makeatother \definecolor{fgcolor}{rgb}{0.345, 0.345, 0.345} \newcommand{\hlnum}[1]{\textcolor[rgb]{0.686,0.059,0.569}{#1}}% \newcommand{\hlstr}[1]{\textcolor[rgb]{0.192,0.494,0.8}{#1}}% \newcommand{\hlcom}[1]{\textcolor[rgb]{0.678,0.584,0.686}{\textit{#1}}}% \newcommand{\hlopt}[1]{\textcolor[rgb]{0,0,0}{#1}}% \newcommand{\hlstd}[1]{\textcolor[rgb]{0.345,0.345,0.345}{#1}}% \newcommand{\hlkwa}[1]{\textcolor[rgb]{0.161,0.373,0.58}{\textbf{#1}}}% \newcommand{\hlkwb}[1]{\textcolor[rgb]{0.69,0.353,0.396}{#1}}% \newcommand{\hlkwc}[1]{\textcolor[rgb]{0.333,0.667,0.333}{#1}}% \newcommand{\hlkwd}[1]{\textcolor[rgb]{0.737,0.353,0.396}{\textbf{#1}}}% \usepackage{framed} \makeatletter \newenvironment{kframe}{% \def\at@end@of@kframe{}% \ifinner\ifhmode% \def\at@end@of@kframe{\end{minipage}}% \begin{minipage}{\columnwidth}% \fi\fi% \def\FrameCommand##1{\hskip\@totalleftmargin \hskip-\fboxsep \colorbox{shadecolor}{##1}\hskip-\fboxsep % There is no \\@totalrightmargin, so: \hskip-\linewidth \hskip-\@totalleftmargin \hskip\columnwidth}% \MakeFramed {\advance\hsize-\width \@totalleftmargin\z@ \linewidth\hsize \@setminipage}}% {\par\unskip\endMakeFramed% \at@end@of@kframe} \makeatother \definecolor{shadecolor}{rgb}{.97, .97, .97} \definecolor{messagecolor}{rgb}{0, 0, 0} \definecolor{warningcolor}{rgb}{1, 0, 1} \definecolor{errorcolor}{rgb}{1, 0, 0} \newenvironment{knitrout}{}{} % an empty environment to be redefined in TeX \usepackage{alltt} \usepackage{mathpazo} \usepackage[T1]{fontenc} \usepackage[latin9]{inputenc} \makeatletter %% LyX specific LaTeX commands. \pdfpageheight\paperheight \pdfpagewidth\paperwidth %% Textclass specific LaTeX commands. \usepackage[natbibapa]{apacite} %% User specified LaTeX commands. \date{} \usepackage{textcomp,url,multicol} %\setkomafont{sectioning}{\rmfamily} \makeatother \usepackage{babel} \IfFileExists{upquote.sty}{\usepackage{upquote}}{} \begin{document} In 1986 Ward described the status of water quality assessment as \textquotedbl{}data rich and information poor\textquotedbl{} \citep{Ward1986}. The authors addressed the lack of science-based design of monitoring location networks; this situation still applies. They defined water quality monitoring as \textquotedbl{}any effort by a government or private enterprise to obtain an understanding of the physical, chemical, and biological characteristics of water via statistical sampling.\textquotedbl{} Of course, their definition also applies to appropriate statistical analyses of the collected data. The data available for the Carlin site (USGS station number 10321000 are in Appendix A. Many documents on data analysis and statistics use small sample sets to illustrate the points the author wants the reader to learn. Real-world environmental data sets frequently are very large so this document uses 52 variables from the total available from the USGS's web site. The first step in analyzing water chemistry data for CWA compliance is reading it into the analytical software and converting column data types as necessary. \begin{knitrout} \definecolor{shadecolor}{rgb}{0.969, 0.969, 0.969}\color{fgcolor}\begin{kframe} \begin{alltt} \hlstd{carlin} \hlkwb{<-} \hlkwd{read.csv}\hlstd{(}\hlstr{"./carlin.csv"}\hlstd{,} \hlkwc{header}\hlstd{=T,} \hlkwc{sep}\hlstd{=}\hlstr{","}\hlstd{,}\hlkwc{stringsAsFactors}\hlstd{=F)} \hlstd{carlin}\hlopt{$}\hlstd{sampdate} \hlkwb{<-} \hlkwd{as.Date}\hlstd{(carlin}\hlopt{$}\hlstd{sampdate)} \end{alltt} \end{kframe} \end{knitrout} Next, check that the data are what you expect to see and convert dates from factors. The site ID number is retained for use when examining multiple stations along the Humboldt River for longitudinal changes and other variables that might affect the measured values. \begin{knitrout} \definecolor{shadecolor}{rgb}{0.969, 0.969, 0.969}\color{fgcolor}\begin{kframe} \begin{alltt} \hlkwd{str}\hlstd{(carlin,} \hlkwc{width}\hlstd{=}\hlnum{60}\hlstd{,} \hlkwc{strict.width}\hlstd{=}\hlstr{'cut'}\hlstd{)} \end{alltt} \
Re: [R] Knitr: setting echo = FALSE globally
Section 5.1.3 of the book "Dynamic Documents with R and knitr" is titled "Global Options". I don't know how to make it more clear for readers to find information on global options in the book. Regards, Yihui -- Yihui Xie Web: http://yihui.name On Mon, Jul 20, 2015 at 12:58 PM, Rich Shepard wrote: > Near the beginning of a LyX document I have a knitr chunk with options > that begin with 'global_options', and includes echo=F. This presents the R > code in that chunk from displaying in the compiled PDF file. However, all > following knitr chunks are included in the PDF file. > > Reading the docs (including the Knitr book) does not show me what I am > doing incorrectly. A pointer to the solution is needed. > > Rich __ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Knitr: setting echo = FALSE globally
Have you tried echo = FALSE instead of echo = F. If that doesn't solve your problem, please provide a minimal reproducible example. Op 20-jul.-2015 20:02 schreef "Rich Shepard" : > Near the beginning of a LyX document I have a knitr chunk with options > that begin with 'global_options', and includes echo=F. This presents the R > code in that chunk from displaying in the compiled PDF file. However, all > following knitr chunks are included in the PDF file. > > Reading the docs (including the Knitr book) does not show me what I am > doing incorrectly. A pointer to the solution is needed. > > Rich > > __ > R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide > http://www.R-project.org/posting-guide.html > and provide commented, minimal, self-contained, reproducible code. > [[alternative HTML version deleted]] __ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] Knitr: setting echo = FALSE globally
Near the beginning of a LyX document I have a knitr chunk with options that begin with 'global_options', and includes echo=F. This presents the R code in that chunk from displaying in the compiled PDF file. However, all following knitr chunks are included in the PDF file. Reading the docs (including the Knitr book) does not show me what I am doing incorrectly. A pointer to the solution is needed. Rich __ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.