【问题标题】:R Steamgraph error: "invalid subscript type list"R Steamgraph 错误:“无效的下标类型列表”
【发布时间】:2015-11-01 04:10:42
【问题描述】:

使用 steamgraph 包时出现以下错误

 library(streamgraph)
 streamgraph(data, "Keys" ,"Box.Office", date = 11-11-2011, interactive=TRUE)
Error in .subset(x, j) : invalid subscript type 'list'

数据样本:

days;Box.Office;Key

1; 2324234;Lucy

2; 123123;Lucy

3; 898989;Lucy

.....

1; 231231;Interstellar

2; 32423;Interstellar

【问题讨论】:

  • * 无法添加蒸汽图标签
  • 在未来,你更有可能通过 github 问题文件获得 pkg 作者的帮助,因为我没有在 SO 上积极监控 [r] streamgraph

标签: r visualization stream-graph


【解决方案1】:

首先,你的代码中有一个错字:Keys 应该是 Key 并且 interactive 参数默认设置为 TRUE,你不需要指定它。

最有可能的问题是streamgraph 不知道如何处理days 列,实际上如果您将days 列更改为可以转换为as.Date 的某些内容(数字或字符)效果很好。

official page 的示例表明所有示例都具有可以解释为有效日期的列(数字或字符),此外,您只需在 R 中键入 streamgraph 即可探索函数的主体,然后您会更仔细地了解它的作用。

使用提供的数据,要允许功能工作,您需要其他信息。这是我将days 列转换为日期的示例。它运作良好并产生情节。

library(streamgraph)
streamgraph(df, "Key" ,"Box.Office", "days")

只需使用这些数据:

df <- structure(list(days = structure(c(0, 1, 2, 0, 1), class = "Date"), 
    Box.Office = c(2324234L, 123123L, 898989L, 231231L, 32423L
    ), Key = c("Lucy", "Lucy", "Lucy", "Interstellar", "Interstellar"
    )), .Names = c("days", "Box.Office", "Key"), row.names = c(NA, 
-5L), class = "data.frame")

【讨论】:

  • @hrbrmstr 你是streamgraph 包的作者!我希望我的回答是详尽的,如果我说的不正确,请随时添加和/或更正它,如果对我学习有用,我非常感谢!
  • @hrbrmstr 非常感谢您的帮助:)。使用您的数据时,我仍然收到错误消息。 test&gt; df &lt;- structure(list(days = structure(c(0, 1, 2, 0, 1), class = "Date"),Box.Office = c(2324234L, 123123L, 898989L, 231231L, 32423L), Key =c("Lucy", "Lucy", "Lucy", "Interstellar", "Interstellar")), .Names = c("days","Box.Office", "Key"), row.names = c(NA, -5L), class = "data.frame")&gt; streamgraph(df, "Key" ,"Box.Office", "days")Error in function_list[[k]](value) : could not find function "arrange"
  • 时间限制* 我使用的代码和你给我的代码完全相同:&gt; df &lt;- structure(list(days = structure(c(0, 1, 2, 0, 1), class = "Date"), Box.Office = c(2324234L, 123123L, 898989L, 231231L, 32423L), Key = c("Lucy", "Lucy", "Lucy", "Interstellar", "Interstellar")), .Names = c("days", "Box.Office", "Key"), row.names = c(NA, -5L), class = "data.frame")&gt; streamgraph(df, "Key" ,"Box.Office", "days")Error in function_list[[k]](value) : could not find function "arrange"
  • @hrbrmstr 谢谢你,这样的初学者错误:)
猜你喜欢
  • 2017-10-05
  • 2012-01-06
  • 1970-01-01
  • 2017-09-27
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2018-10-24
  • 1970-01-01
相关资源
最近更新 更多