Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ESS does not deal well with data.table and knitr

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
like image 400
Rodrigo Avatar asked Nov 12 '22 04:11

Rodrigo


1 Answers

Most likely an environment issue. This should solve it:

(setq ess-swv-processing-command "%s(%s)")
like image 124
VitoshKa Avatar answered Nov 15 '22 13:11

VitoshKa