Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/r/65.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
r推特软件包_R_Twitter - Fatal编程技术网

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