尝试子集数据时出错

时间:2015-07-13 05:43:12

标签: r subset

我正在尝试对数据进行分组,并收到一条奇怪的错误消息:

Error in bmerge(i <- shallow(i), x, leftcols, rightcols, io <- haskey(i),  : 
typeof x.cikcode (integer) != typeof i.V1 (character)

我正在使用代码

newdata <- mydata[c("V1","V2", "V2")]  

下面是数据,由于某些原因不能直接在R中运行,即使我在运行dput后将代码复制并粘贴到R中:

structure(list(cikcode = c(NA_integer_, NA_integer_, NA_integer_
), auditorkey = c(NA_character_, NA_character_, NA_character_
), yearendeddate = structure(c(16251, 16251, 16435), class = "Date"), 
    source = structure(c(1L, 1L, 1L), .Label = "", class = "factor"), 
    sourcedate = structure(c(1L, 1L, 1L), .Label = "", class = "factor"), 
    financialsdate = structure(c(1L, 1L, 1L), .Label = "", class = "factor"), 
    auditopinionkey = c(NA_integer_, NA_integer_, NA_integer_
    ), auditorstatecode = structure(c(1L, 1L, 1L), .Label = "", class = "factor"), 
    auditorstatename = structure(c(1L, 1L, 1L), .Label = "", class = "factor"), 
    goingconcern = structure(c(1L, 1L, 1L), .Label = "", class = "factor"), 
    goingconcernissuekeylist = structure(c(1L, 1L, 1L), .Label = "", class = "factor"), 
    goingconcernissuephraselist = structure(c(1L, 1L, 1L), .Label = "", class = "factor"), 
    isadditionalopinion = structure(c(1L, 1L, 1L), .Label = "", class = "factor"), 
    restatement = c(NA_integer_, NA_integer_, NA_integer_), yearended = c(NA_character_, 
    NA_character_, NA_character_), assets = c(NA_character_, 
    NA_character_, NA_character_), auditfees = c(NA_character_, 
    NA_character_, NA_character_), auditor = c(NA_character_, 
    NA_character_, NA_character_), earnings = c(NA_character_, 
    NA_character_, NA_character_), naicscode = c(NA_character_, 
    NA_character_, NA_character_), revenue = c(NA_character_, 
    NA_character_, NA_character_), siccode = c(NA_integer_, NA_integer_, 
    NA_integer_), statecode = c(NA_character_, NA_character_, 
    NA_character_), statename = c(NA_character_, NA_character_, 
    NA_character_), ticker = c(NA_character_, NA_character_, 
    NA_character_), restatedperiodbegin = structure(c(1L, 1L, 
    2L), .Label = c("2014-06-30", "2014-12-31"), class = "factor"), 
    restatedperiodended = structure(c(1L, 1L, 2L), .Label = c("2014-06-30", 
    "2014-12-31"), class = "factor")), .Names = c("cikcode", 
auditorkey, "yearendeddate", "source", "sourcedate", "financialsdate", 
auditopinionkey, "auditorstatecode", "auditorstatename", "goingconcern", 
goingconcernissuekeylist, "goingconcernissuephraselist", "isadditionalopinion", 
restatement, "yearended", "assets", "auditfees", "auditor", 
earnings, "naicscode", "revenue", "siccode", "statecode", "statename", 
ticker, "restatedperiodbegin", "restatedperiodended"), sorted = c("cikcode", 
restatedperiodbegin, "restatedperiodended"), row.names = c(NA, 
-3L), .internal.selfref = <pointer: 0x05bf24a0>, class = c("data.table", 
data.frame))

我收到了莫名其妙的错误:

Error: unexpected '<' in:
 "    restatedperiodbegin, "restatedperiodended"), row.names = c(NA, 
 -3L), .internal.selfref = <"
 >     data.frame))
 Error: unexpected ')' in "    data.frame)"

0 个答案:

没有答案