0

I'd like to locate the specific chunk (or better yet, line of code) that generates a warning message when compiling a knitr PDF in RStudio. This is the final piece of info that knitr outputs after successfully running every chunk:

.....
output file: file.tex

[1] "file.tex"
Warning message:
In bmerge(i, x, leftcols, rightcols, io <- FALSE, xo, roll = 0,  :
  A known encoding (latin1 or UTF-8) was detected in a join column. data.table compares the 
bytes currently, so doesn't support *mixed* encodings well; i.e., using both latin1 and UTF-8, 
or if any unknown encodings are non-ascii and some of those are marked known and others not. 
But if either latin1 or UTF-8 is used exclusively, and all unknown encodings are ascii, then 
the result should be ok. In future we will check for you and avoid this warning if everything 
is ok. The tricky part is doing this without impacting performance for ascii-only cases.
Running xelatex on file.tex...completed

Created PDF: ~/Documents/file.pdf

Why is the warning not displayed with the chunk that generated it? In an effort to locate its source, I've tried turning on opts_chunk$set(warning=TRUE, message=TRUE, echo=TRUE, but the warning message doesn't show up in the final PDF. I've also stepped through the many chunks individually and don't seem to get this warning in the R console (in fact I only employ a single merge() and the by= is an integer). Any other suggestions for tracking it down? I'm running the latest CRAN versions of knitr 1.8 and data.table 1.94, along with RStudio 0.98.1091.

Community
  • 1
  • 1
Bryan
  • 1,771
  • 4
  • 17
  • 30
  • 1
    Maybe try setting `options(warn=2)`, to turn warnings into errors [as, e.g. here](http://stackoverflow.com/questions/8217901/breaking-loop-when-warnings-appear-in-r/8217929#8217929)? – Josh O'Brien Dec 03 '14 at 21:18
  • 1
    @JoshO'Brien, thanks, using `options(warn=1) # print warnings as they occur` pushed the error to display in the knitr output right where it occurred (it turns out it was from an inline expression between two chunks). Super helpful. – Bryan Dec 03 '14 at 22:16
  • Aha, very cool. I'll have to keep in mind that bit about warnings in inline expressions. Hadn't thought of that. – Josh O'Brien Dec 03 '14 at 22:53

0 Answers0