簡體   English   中英

R Steamgraph錯誤:“無效的下標類型列表”

[英]R Steamgraph error: “invalid subscript type list”

使用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

首先,代碼中有一個拼寫錯誤: Keys應該為Key ,默認情況下, interactive參數設置為TRUE ,您無需指定它。

最有可能的問題是streamgraph不知道如何處理days列,實際上,如果您使用可以轉換為as.Date東西(數字或字符)來更改days列,它就可以很好地工作。

官方頁面的示例顯示,所有示例均具有可解釋為有效日期的列(數字或字符),此外,您只需在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")

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM