yihui / knitr-examples

A collection of knitr examples
484 stars 587 forks source link

"Error: character argument expected" when using knit_child #34

Closed johnbaums closed 9 years ago

johnbaums commented 9 years ago

Attempting to compile this Rnw to PDF in RStudio 0.98.1056 fails with the error:

Writing to file 021-ggplot2-geoms.tex
Processing code chunks with options ...
 1 : echo keep.source term verbatim (label = setup, 021-ggplot2-geoms.Rnw:8)
 2 : echo keep.source term verbatim (label = write-examples, 021-ggplot2-geoms.Rnw:15)
Error: at 021-ggplot2-geoms.Rnw:26, character argument expected
Execution halted
R version 3.1.1 (2014-07-10)
Platform: x86_64-w64-mingw32/x64 (64-bit)

Removing the line:

\Sexpr{knit_child(text = unlist(ex), quiet = TRUE)}

causes it to compile successfully.

Here's my sessionInfo():

locale:
[1] LC_COLLATE=English_Australia.1252  LC_CTYPE=English_Australia.1252    LC_MONETARY=English_Australia.1252 LC_NUMERIC=C                      
[5] LC_TIME=English_Australia.1252    

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base     

other attached packages:
[1] knitr_1.6.21  ggplot2_1.0.0

loaded via a namespace (and not attached):
 [1] colorspace_1.2-4 digest_0.6.4     evaluate_0.5.5   formatR_1.0      grid_3.1.1       gtable_0.1.2     MASS_7.3-35      munsell_0.4.2   
 [9] plyr_1.8.1       proto_0.3-10     Rcpp_0.11.3      reshape2_1.4     scales_0.2.4     stringr_0.6.2    tools_3.1.1 
yihui commented 9 years ago

Apparently (well, maybe not apparent to you), you were using Sweave to compile the Rnw file. You need to change the RStudio option to use knitr instead.

johnbaums commented 9 years ago

Thanks for looking into it, yihui. :)