【问题标题】:GoogleVis not working in R: Motion chart not loading in the browser. Getting blank browserGoogleVis 在 R 中不工作:动态图表未在浏览器中加载。获取空白浏览器
【发布时间】:2014-01-13 05:59:01
【问题描述】:

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

  1. 我使用了内置的 R 数据集“ChickWeight”
  2. 已安装 RJSONIO 和 googleVis 包。
  3. 为简单起见,我将 ChickWeight 数据帧截断为 24 行:ChickWeight1
  4. 然后调用 gvisMotionChart 函数,为其分配一个对象: 可视化1
  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 笔记本电脑上运行了相同的代码,但没有运气。

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

【问题讨论】:

    标签: r google-visualization googlevis


    【解决方案1】:

    您输入后得到的完整错误:

    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 很有用。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2016-05-12
      • 1970-01-01
      • 1970-01-01
      • 2017-08-05
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多