Discussion:
R warn Option Ignored
d***@gmail.com
2013-08-08 06:00:15 UTC
Permalink
One of the first code chunks in my file is

<<label = SETUP, echo=FALSE>>=
options(prompt = " ", continue = " ", width = 90, scipen = 9, warn = -1)
setwd("/nb/dario/projects/CAGE")
library(knitr)
opts_chunk$set(tidy = FALSE)
@

However, when I see my final PDF, I notice the warnings have been included.

e.g.

hyperTable <-
read.table("/nb/dario/resources/wgEncodeRegDnaseClustered.bed",
sep = '\t')

## Warning: cannot open file
'/nb/dario/resources/wgEncodeRegDnaseClustered.bed': No such
file or directory
## Error: cannot open the connection

I realise I have to fix the path, but why is warn = -1 ignored ? It's also
weird that it appears as both a warning and an error message.
--
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+***@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
Yihui Xie
2013-08-08 06:29:49 UTC
Permalink
Internally warn is set to 1 so that warnings are always recorded. The
correct way to discard warnings is through the chunk option
warning=FALSE: http://yihui.name/knitr/options

Note you almost never need to setwd(); please read ?knit to know more
information about the working directory.

Regards,
Yihui
--
Yihui Xie <***@gmail.com>
Phone: 206-667-4385 Web: http://yihui.name
Fred Hutchinson Cancer Research Center, Seattle
Post by d***@gmail.com
One of the first code chunks in my file is
<<label = SETUP, echo=FALSE>>=
options(prompt = " ", continue = " ", width = 90, scipen = 9, warn = -1)
setwd("/nb/dario/projects/CAGE")
library(knitr)
opts_chunk$set(tidy = FALSE)
@
However, when I see my final PDF, I notice the warnings have been included.
e.g.
hyperTable <-
read.table("/nb/dario/resources/wgEncodeRegDnaseClustered.bed",
sep = '\t')
## Warning: cannot open file
'/nb/dario/resources/wgEncodeRegDnaseClustered.bed': No such
file or directory
## Error: cannot open the connection
I realise I have to fix the path, but why is warn = -1 ignored ? It's also
weird that it appears as both a warning and an error message.
--
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
For more options, visit https://groups.google.com/groups/opt_out.
--
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+***@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
Loading...