Re: [knitr] Control the output of errors messages etc.

1,632 views
Skip to first unread message

Yihui Xie

unread,
Jun 7, 2013, 1:56:04 PM6/7/13
to Karl Sinn, kn...@googlegroups.com
Hi,

You need to set these options in an earlier chunk. When you set them
in the current chunk, it is too late.

Regards,
Yihui
--
Yihui Xie <xiey...@gmail.com>
Phone: 515-294-2465 Web: http://yihui.name
Department of Statistics, Iowa State University
2215 Snedecor Hall, Ames, IA


On Fri, Jun 7, 2013 at 7:00 AM, Karl Sinn <karl...@gmail.com> wrote:
> Hi,
>
> I'm a total beginner with knitr and I'm hitting some problems I can't solve:
>
> That's my *.Rmd file:
> -----begin
> Achtsamkeit und Intergruppenangst
> ========================================================
>
> This is an R Markdown document. Markdown is a simple formatting syntax for
> authoring web pages (click the **MD** toolbar button for help on Markdown).
>
> When you click the **Knit HTML** button a web page will be generated that
> includes both content as well as the output of any embedded R code chunks
> within the document. You can embed an R code chunk like this:
>
>
> ```{r}
> opts_chunk$set(comment="test",results="hide",warning=FALSE,error=FALSE,message=FALSE)
> source("Vorbereitungen.R")
> source("Analysen.R")
> ```
> -----end
>
> As you can see, I tried to turn off all the warnings, messages and errors. I
> tried to set the comment option to "test".
> But as you can see in the following *.md file, that was created using
> RStudio, the options are simply ignored.
>
> How can I switch off the output of for example loaded libraries?
> Thanks
> Karl
>
> *.md document:
> -----begin
> Achtsamkeit und Intergruppenangst
> ========================================================
>
> This is an R Markdown document. Markdown is a simple formatting syntax for
> authoring web pages (click the **MD** toolbar button for help on Markdown).
>
> When you click the **Knit HTML** button a web page will be generated that
> includes both content as well as the output of any embedded R code chunks
> within the document. You can embed an R code chunk like this:
>
>
>
> ```r
> opts_chunk$set(comment = "test", results = "hide", warning = FALSE, error =
> FALSE,
> message = FALSE)
> source("Vorbereitungen.R")
> ```
>
> ```
> ## Loading required package: MASS
> ```
>
> ```
> ## Loading required package: boot
> ```
>
> ```
> ## Attaching package: 'boot'
> ```
>
> ```
> ## The following object(s) are masked from 'package:psych':
> ##
> ## logit
> ```
>
> ```
> ## Loading required package: mnormt
> ```
>
> ```
> ## Loading required package: pbivnorm
> ```
>
> ```
> ## Loading required package: quadprog
> ```
>
> ```
> ## This is lavaan 0.5-12
> ```
>
> ```
> ## lavaan is BETA software! Please report any bugs.
> ```
>
> ```
> ## Duplikate, Vpn_CODE: VORSICHT damit muss man noch umgehen
> ```
>
> ```
> ## Error: Objekt 'stichprobe' nicht gefunden
> ```
>
> ```r
> source("Analysen.R")
> ```
>
> ```
> ## Error: Fehler bei der Auswertung des Argumentes 'object' bei der
> ## Methodenauswahl für Funktion 'summary': Fehler in eval(expr, envir,
> ## enclos) : Objekt 'skala.stadis' nicht gefunden Calls: aov ... eval ->
> ## model.frame -> model.frame.default -> eval -> eval
> ```
> -----end
>
>
> --
> You received this message because you are subscribed to the Google Groups
> "knitr" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to knitr+un...@googlegroups.com.
> For more options, visit https://groups.google.com/groups/opt_out.
>
>

Karl Sinn

unread,
Jun 11, 2013, 8:41:57 AM6/11/13
to kn...@googlegroups.com, Karl Sinn
Hi,

thanks for the fast answer.

Is it possible to change these settings within one document?
Do I have to always do this just one chunk before I want them to be applied?

Thanks
Karl

baptiste auguie

unread,
Jun 11, 2013, 8:46:23 AM6/11/13
to Karl Sinn, kn...@googlegroups.com
Hi,

Typically you set such options in a first invisible chunk at the top of your document, and it will apply to all subsequent chunks.

b.

Yihui Xie

unread,
Jun 11, 2013, 2:12:57 PM6/11/13
to baptiste auguie, Karl Sinn, kn...@googlegroups.com
Exactly. In other words, they are _global_ settings within a document.

Regards,
Yihui
--
Yihui Xie <xiey...@gmail.com>
Phone: 515-294-2465 Web: http://yihui.name
Department of Statistics, Iowa State University
2215 Snedecor Hall, Ames, IA


Karl Sinn

unread,
Jun 11, 2013, 2:35:01 PM6/11/13
to kn...@googlegroups.com, baptiste auguie, Karl Sinn
I see,

thanks
Karl
Reply all
Reply to author
Forward
0 new messages