2014-10-16 42 views
-1

我使用下列數據集的時間表庫:爲什麼我會得到未定義的列err?

'data.frame': 3951 obs. of 4 variables: 
$ Problem : chr "A" "B" "C" "D" ... 
$ Device : chr "V" "W" "V" "W" ... 
$ StartDate: Date, format: "2008-01-24" "2008-01-11" ... 
$ EndDate : Date, format: "2007-11-25" "2007-10-16" ... 

這正是由庫的二戰所提供的相同的數據結構:

'data.frame': 8 obs. of 4 variables: 
$ Person : chr "Franklin D. Roosevelt" "Harry S. Truman" "Stanley\nBaldwin" "Neville\nChamberlain" ... 
$ Group : chr "US President" "US President" "UK Prime Minister" "UK Prime Minister" ... 
$ StartDate: Date, format: "1933-03-04" "1945-04-12" ... 
$ EndDate : Date, format: "1945-04-12" "1953-01-20" ... 

我跑後

timeline(df,group.col=df$Problem,start.col=df$StartDate,end.col=df$EndDate) 

返回

Error in `[.data.frame`(df, , start.col) : undefined columns selected 

即使我嘗試不同的str,如df [,1],它也會返回相同的錯誤。我誤解了什麼?

+0

如果您發佈dput(DF)的輸出這裏將是有益的。 – rnso 2014-10-16 13:25:07

回答

1

研究的文件,然後使用:

timeline(df, group.col="Problem", 
      start.col="StartDate", 
      end.col="EndDate") 
+0

時間軸(df,events,label.col = names(df)[1], group.col = names(df)[2],start.col = names(df)[3], end.col = names (df)[4],text.size = 4, text.color =「black」,num.label.steps = 5, event.label.col,event.col,event.group.col, event。點號= 1,event.label =「」, event.label.method = 1,event.line = FALSE, event.text.size = 4,event.above = TRUE,限制......) – Aaron 2014-10-16 18:56:40

+0

格式在最初的文章中提出的最後一句中提供的文檔與文檔中提供的格式相匹配,謝謝。 – Aaron 2014-10-16 19:03:52

+0

實際上還有另一個問題,對我的理解更加準確,這與閱讀文檔有關---爲什麼選擇「問題」而不是df [,「問題」](?不確定這個問題),df [ ,1]或df $問題。它們都是解釋文件的合法方式。 – Aaron 2014-10-16 19:12:34

相關問題