答案可能很簡單,但我被卡住了:如何獲得R輸出到CSV文件?
我使用Twitter API 1.1獲取某個帳戶的推文。通過使用以下功能
user <- getUser("xxx")
userTimeline(user, n=300, maxID=NULL, sinceID=NULL, includeRts=FALSE)
我收到大約150條推文。它看起來像這樣:
[[125]]
[1] "AlexSalmond: Many thanks to @welovehistory carpentry & joinery apprentice Hannah Ross for the table she's built for Bute House http://t.co/1CnuACirLC"
[[126]]
[1] "AlexSalmond: Well done to all involved in #ArmedForcesDay & #BannockburnLive â€「 making Stirling’s Big Weekend a massive success http://t.co/ho3Az1O9cF"
[[127]]
[1] "AlexSalmond: Enjoyed conversation and public Q&A with @DerekBateman2 last week â€「 you can listen here: http://t.co/alCkf14zij #IndyRef"
如何將這些數據保存到csv文件?
通過使用write.csv
它給了我下面的錯誤:
Error in as.data.frame.default(x[[i]], optional = TRUE) :
cannot coerce class "structure("user", package = "twitteR")" to a data.frame
強制其一個data.frame或矩陣。 'write.table'或'write.csv'應該可以工作。或者,你可以'writeLines'來寫每個列表元素。 – 2014-10-01 09:39:04