【发布时间】:2013-06-27 20:13:31
【问题描述】:
大家好 Stackoverflow。 我是 R 新手,遇到 lapply 功能问题。
现在我使用的是 R 版本 3.0.1 (2013-05-16) -- “Good Sport” 在 Ubuntu 服务器 12.04.2 LTS 上运行。
我的问题是我无法使用 lapply 函数将 searchTwitter(在 twitteR 中)的输出转换为数据框。
我可以将推文收集到“推文”变量中,但无法转换为数据框。
我的代码:
require(twitteR)
require(RJSONIO)
load('cred.Rdata')
registerTwitterOAuth(cred)
tweet <- searchTwitter('bus')
tweet1 <- lapply(tweet, as.data.frame) //error here
df <- do.call("rbind",tweet1)
write.csv(df,file='oneearthquake.csv')
我得到了错误:
Error in data.frame(text= "(tweet text)")
arguments imply differing number of rows: 1,0
我在另一台运行相同 R 版本的 Ubuntu 服务器上进行了尝试,它可以在没有任何警告的情况下运行。能告诉我解决这个错误的方法吗?
提前谢谢你
谋略
【问题讨论】:
-
你试过
twListToDF或答案here吗?它们可能有点过时了...... -
我试过了,还是一样。
标签: r list twitter dataframe lapply