This seems to be a recurrent problem for who is willing to write dynamic documents with knitr
in RStudio
(see also here for instance).
Unfortunately I haven't find a solution on Stack Overflow or by googling more in general.
Here is a toy example I am trying to compile in RStudio. It is the minimal-example-002.Rnw
(link):
\documentclass{article}
\usepackage[T1]{fontenc}
\begin{document}
Here is a code chunk.
<<foo, fig.height=4>>=
1+1
letters
chartr('xie', 'XIE', c('xie yihui', 'Yihui Xie'))
par(mar=c(4, 4, .2, .2)); plot(rnorm(100))
@
You can also write inline expressions, e.g. $\pi=\Sexpr{pi}$, and \Sexpr{1.598673e8} is a big number.
\end{document}
My problem is that I am not able to compile the pdf in RStudio
by using knitr
, while by changing the default weaving option to sweave
I get the final pdf.
More specifically, I work in Windows 7, latest RStudio version (0.98.1103), I weave the file using the knitr option and I disabled the "always enable Rnw concordance" box.
Did this happen to you? Any help would be highly appreciated, thank you very much.
EDIT
Apparently it is not an RStudio problem, as I tried to compile the document from R with:
library('knitr')
knit('minimal_ex.Rnw')
and I get the same error:
processing file: minimal_ex.Rnw
|
| | 0%
|
|...................... | 33%
ordinary text without R code
|
|........................................... | 67%
label: foo (with options)
List of 1
$ fig.height: num 4
Quitting from lines 8-10 (minimal_ex.Rnw)
Errore in data.frame(..., check.names = FALSE) :
arguments imply differing number of rows: 3, 0
Inoltre: Warning messages:
1: In is.na(res[, 1]) :
is.na() applied to non-(list or vector) of type 'NULL'
2: In is.na(res) : is.na() applied to non-(list or vector) of type 'NULL'
EDIT 2:
This is my session info:
R version 3.1.1 (2014-07-10)
Platform: x86_64-w64-mingw32/x64 (64-bit)
locale:
[1] LC_COLLATE=Italian_Italy.1252 LC_CTYPE=Italian_Italy.1252 LC_MONETARY=Italian_Italy.1252 LC_NUMERIC=C
[5] LC_TIME=Italian_Italy.1252
attached base packages:
[1] stats graphics grDevices utils datasets methods base
other attached packages:
[1] knitr_1.10.5
loaded via a namespace (and not attached):
[1] tools_3.1.1
knitr
andsweave
. Isminimal_ex.tex
created? – Robert