2

我在让 GoogleVis 工作时遇到问题。当我使用 GoogleVis 绘图时,我得到一个空白浏览器。这是我所做的:

  1. 我使用了内置的 R 数据集“ChickWeight”
  2. 安装了 RJSONIO 和 googleVis 包。
  3. 为简单起见,我将 ChickWeight 数据帧截断为 24 行: ChickWeight1<-ChickWeight[1:24,]
  4. 然后调用 gvisMotionChart 函数,为其分配一个对象:visualization1<-gvisMotionChart(ChickWeight1,idvar='weight',timevar='Time')
  5. 运行上面的代码给了我一个警告信息。不确定警告消息是否相关:

警告消息:在 if (class(x[[.x]]) == "Date") as.character(x[[.x]]) else x[[.x]] 中:条件的长度 > 1 并且只使用第一个元素

  1. 然后我绘制了对象: plot(visualization1)

我期待一个动态图表,但我只有一个空白浏览器。我还尝试将“时间”列从数字类转换为日期类,但没有运气。

我正在使用 R 3.0.2、Mac OS X 版本 10.6.8 和 Safari 版本 5.1.2 (6534.52.7)。我也在我的工作 Windows 笔记本电脑上运行了相同的代码,但没有运气。

任何反馈将不胜感激!谢谢!

4

1 回答 1

3

输入后得到的完整错误:

mchart1<-gvisMotionChart(ChickWeight1,idvar='weight',timevar='Time') 曾是:

Error in gvisCheckMotionChartData(data, my.options) : The data must have rows with unique combinations of idvar and timevar. Your data has 578 rows, but idvar and timevar only define 375 unique rows. In addition: Warning message: In if (class(x[[.x]]) == "Date") as.character(x[[.x]]) else x[[.x]] : the condition has length > 1 and only the first element will be used

这个错误会让你知道你没有指定小鸡的 ID。如果您这样做,mchart1<-gvisMotionChart(ChickWeight,idvar='Chick',timevar='Time')这将为您提供小鸡如何随时间增加体重的运动图。

?gvisMotionChart非常有用。

于 2014-02-10T21:19:18.083 回答