r推特软件包
我正在读推特软件包。对于r推特软件包,r,twitter,R,Twitter,我正在读推特软件包。对于searchTwitter,它表示R返回状态对象列表状态类文档列出了几个字段和方法 但是如下所示,class(x)返回list,为什么?它不应该返回状态对象吗?最后两个命令也不起作用,为什么 文件上说 toDataFrame: Converts this into a one row data.frame, with each field representing a column. This can also be accomplished by the S4 sty
searchTwitter
,它表示R返回状态对象列表<代码>状态类
文档列出了几个字段和方法
但是如下所示,class(x)
返回list
,为什么?它不应该返回状态对象吗?最后两个命令也不起作用,为什么
文件上说
toDataFrame: Converts this into a one row data.frame, with each field
representing a column.
This can also be accomplished by the S4 style as.data.frame(objectName)
x=searchTwitter("Samsung")
> class(x)
[1] "list"
> abc=as.data.frame(x)
Error in as.data.frame.default(x[[i]], optional = TRUE) :
cannot coerce class "structure("status", package = "twitteR")" to a data.frame
> x$text
NULL
如果
x
是状态对象的列表,则x
的类是list
。列表中每个元素的类都是状态类
您可以尝试以下方法:
class(x[[1]])
检查这是否正确
类似地,toDataFrame
作用于类状态类的对象
——同样,作用于列表的元素,而不是列表本身。您可以尝试:
toDataFrame(x[[1]])
及
如果您的目标是将列表中的每个元素放入单个数据框中,那么您应该查看的函数是
twListToDF
如果x
是状态对象的列表,那么x
的类就是list
。列表中每个元素的类都是状态类
您可以尝试以下方法:
class(x[[1]])
检查这是否正确
类似地,toDataFrame
作用于类状态类的对象
——同样,作用于列表的元素,而不是列表本身。您可以尝试:
toDataFrame(x[[1]])
及
如果您的目标是将列表中的每个元素放入单个数据框中,那么您应该查看的函数是twListToDF