2014-09-12 43 views
2

當我嘗試在slidingify中添加(data.table/ggplot2)代碼時,出現錯誤。 這是我在slidify代碼:slidingify + data.table(ggplot2)錯誤

## data.table 
```{r} 
library(data.table) 
DT = data.table(x = 1:5, y=6:10) 
setkey(DT, x) 
DT[J(1)] # Error: No J function 
``` 
--- 
## ggplot2 
```{r} 
library(ggplot2) 
a = b = shape = 1:5 
ggplot(data=DT, aes(a, b, col=shape)) + geom_point() # Error: can not find object a 
``` 

所有的代碼可以運行外slidify,所以我想有一些關於變量命名錯slidify。

我也找到這個鏈接:data.table error when used through knitr, gWidgetsWWW這可能與我的問題類似,但仍不知道如何解決。

+0

請問您可以給[當前開發版本](https://github.com/Rdatatable/data.table)一試嗎? – Arun 2014-09-13 01:18:43

+0

令我驚訝的是,它的工作原理。我認爲這是slideify的問題,導致ggplot2命令無法運行。謝謝! – 2014-09-13 02:13:13

+0

有趣:我可以運行第一部分。但是ggplot命令會拋出錯誤##錯誤:提供給離散量程的連續值 – JerryWho 2014-09-15 06:38:18

回答

0

只需添加一個答案,以跟進對問題的評論。 data.table的dev版本修復了它,現在在CRAN(data.table v1.9.4)上。但是這打破了針織者v1.7(在CRAN上)修復的針織者kable()。所以基本上,升級到最新的CRAN版本的knitr和data.table,你應該沒問題。請告訴我們,如果沒有。爲好奇


更多細節...

我做了另一個變化到v1.9.5 data.table以使其更加堅固爲評估用戶代碼(如knitr,slidify和包gWidgetsWWW),但不知道data.table本身。這樣他們以後不需要知道。下面是該項目:

knitr::kable() works again without needing to upgrade from knitr v1.6 to v1.7. Packages which evaluate user code and don't wish to import data.table need to be added to data.table:::cedta.pkgEvalsUserCode and now only the eval part is made data.table-aware (the rest of such package's code is left data.table-unaware). data.table:::cedta.override is now empty and will be deprecated if no need for it arises.

,這裏是在v1.9.4這是一個有點太過分達到並打破knitr :: kable在knitr V1.6和V1.7 knitr修復的項目(但不應該」 t需要):

Added shiny, rmarkdown and knitr to the data.table whitelist. Packages which take user code as input and run it in their own environment (so do not Depend or Import data.table themselves) either need to be added here, or they can define a variable .datatable.aware <- TRUE in their namepace, so that data.table can work correctly in those packages. Users can also add to data.table's whitelist themselves using assignInNamespace() but these additions upstream remove the need to do that for these packages.