我正在尝试与ggvis
结合运行data.table
,请参见下面的代码。我收到以下错误:
Error in `:=`(mpg2, mpg/2) :
Check that is.data.table(DT) == TRUE. Otherwise, := and `:=`(...)
are defined for use in j, once only and in particular ways. See help(":=").
如果我mtcars[ , mpg2 := mpg / 2]
在控制台中运行该行,则没有问题。那么问题是什么?[我仍然对两者data.table
都ggvis
使用:=
.
---
title: "Untitled"
output: html_document
runtime: shiny
---
```{r echo = FALSE}
library(ggvis)
library(data.table)
mtcars %>%
ggvis(x = ~wt, y = ~mpg) %>%
layer_points()
mtcars = data.table(mtcars)
mtcars[, mpg2 := mpg / 2] # gives error message
# code below does not work as the line above throws an error
mtcars %>%
ggvis(x = ~wt, y = ~mpg2) %>%
layer_points()
```
data.table
版本 1.9.2
ggvis
来自 github 0.3.0.9001,因为 CRAN 版本抱怨缺少knit_print
.