3

我正在尝试与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.tableggvis使用:=.

---
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.

4

1 回答 1

0

我已经更新到 data.table 1.9.3 并且一切正常。谢谢!

于 2014-08-19T10:35:21.310 回答