2014-10-16 112 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

相关问题