I am having trouble in evaluating variables inside data.table[...]
when using knitr
. I have seen answers to this problem stating it is solved, but I am still getting errors. I am using data.table
version 1.8.8 on R 3.0.0.
I am using Emacs 24.3 that comes with ESS 13.05. Here's a sample .Rnw file:
\documentclass{article}
\begin{document}
<<init,eval=TRUE, cache=FALSE>>=
require(data.table)
dt <- data.table(x=1:10, y=11:20)
dt
dt[x > 5]
@
\end{document}
and corresponding (pdf) output:
require(data.table)
## Loading required package: data.table
## data.table 1.8.8 For help type: help("data.table")
dt <- data.table(x = 1:10, y = 11:20)
dt
## x y
## 1: 1 11
## 2: 2 12
## 3: 3 13
## 4: 4 14
## 5: 5 15
## 6: 6 16
## 7: 7 17
## 8: 8 18
## 9: 9 19
## 10: 10 20
dt[x > 5]
## Error: object ’x’ not found
Most likely an environment issue. This should solve it:
(setq ess-swv-processing-command "%s(%s)")
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With