我有一個簡單的循環來寫過去100個鳴叫幾個用戶名的爲.csv文件:轉換Twitter的結果,以數據幀
library(twitteR)
mclist <- read.table('usernames.txt')
for (mc in mclist)
{
tweets <- userTimeline(mc, n = 100)
df <- do.call("rbind", lapply(tweets, as.data.frame))
write.csv(df, file=paste("Desktop/", mc, ".csv", sep = ""), row.names = F)
}
我大多沿用我讀過StackOverflow上,但我繼續得到這個錯誤信息:
Error in file(file, ifelse(append, "a", "w")) :
invalid 'description' argument
In addition: Warning message:
In if (file == "") file <- stdout() else if (is.character(file)) { :
the condition has length > 1 and only the first element will be used
我哪裏出錯了?
您正在向您的循環傳遞數據幀。循環遍歷數據幀將遍歷每個元素,即每列。你想傳遞一個向量到循環,即像'mclist [,1]''。 – Andrie
雖然我仍然得到相同的錯誤 - 有關對象userTimeline的問題似乎是問題所在 – Emir