0
拯救我的微博,當我收集它們並應用,所以我有麻煩sapply上他們,他們以這種形式出現R:Twitter的鳴叫收集
some_txt = sapply(tweets, function(x) x$getText())
[1] "RT @JanoImLukesSlut: #HarryHas17MillionFollowParty\nâ™」 RT\nâ™」Follow me\nâ™」Ask4follow back\nâ™」Follow ALL who RTs\nâ™」Gain\nâ™」Drink pepsi feel sexyyy\n#Sto…"
[2] "RT @abria_valerie: Pepsi is like crack to me. I gotta have it."
[3] "@JLinn6 having to stop for dr. Pepper bc someone doesn't like Pepsi. #picky #spoiledbrat #watchoutonlylikesdr.'s"
[4] "RT @cyberscott1975: The coca cola truck can bugger off! I want a Pepsi Max Xmas Truck!í ½íºš"
[5] "í ½í²•í ½í²•í ½í²•Mmm That Spicy Chicken Sandwich And Fries And Pepsi From Wendy's Was A1í ½í²¦"
[6] "@JatnnaP05 @Alexandergr_ @IannErnesto @WilberJE ENTRA dale a GALERIA luego vota por : attabeira https://t.co/hh0Q5tkHzx #HelpMe"
[7] "RT @supersunnytime: wallowing in a sea of pop punk and self-hatred"
[8] "These bitches love soda Pepsi and Cola"
[9] "RT @Lmao: waiter: \"what drink would you like\" \nme: \"тнÑ」 вâ„「σσ∂ σƒ му Ñ」ηÑ」мιÑ」Ñ•\" \nwaiter: \nme: \nwaiter: \nme: \nwaiter: \nme: \nwaiter: \"is pepsi o…"
.......................
但是當我申請一個寫CSV它。然後讀回了它不回來相同的格式
write.csv(some_txt, file = file.choose(), row.names = TRUE, sep = ',', col.names = TRUE)
some_txt = read.csv(file.choose(), row.names = 1, sep = ',')
它,而不是回來爲
x
1 RT @JanoImLukesSlut: #HarryHas17MillionFollowParty\nâ™」 RT\nâ™」Follow me\nâ™」Ask4follow back\nâ™」Follow ALL who RTs\nâ™」Gain\nâ™」Drink pepsi feel sexyyy\n#Sto…
2 RT @abria_valerie: Pepsi is like crack to me. I gotta have it.
3 @JLinn6 having to stop for dr. Pepper bc someone doesn't like Pepsi. #picky #spoiledbrat #watchoutonlylikesdr.'s
4 RT @cyberscott1975: The coca cola truck can bugger off! I want a Pepsi Max Xmas Truck!í ½íºš
5 í ½í²•í ½í²•í ½í²•Mmm That Spicy Chicken Sandwich And Fries And Pepsi From Wendy's Was A1í ½í²¦
6 @JatnnaP05 @Alexandergr_ @IannErnesto @WilberJE ENTRA dale a GALERIA luego vota por : attabeira https://t.co/hh0Q5tkHzx #HelpMe
7 RT @supersunnytime: wallowing in a sea of pop punk and self-hatred
8 These bitches love soda Pepsi and Cola
9 RT @Lmao: waiter: "what drink would you like" \nme: "тнÑ」 вâ„「σσ∂ σƒ му Ñ」ηÑ」мιÑ」Ñ•" \nwaiter: \nme: \nwaiter: \nme: \nwaiter: \nme: \nwaiter: "is pepsi o…
......
如何還給相同價值的想法?我使用csv,因爲我想手動收集這些推文。
這是some_txt的STR()爲例(這是50鳴叫所以它1:50)
chr [1:50] "@psychicpebble AMEN THANK YOU FOR NOT TALKING ABOUT THAT PEPSI SHIT." ...
編輯:
這是閱讀後輸出的STR()例子(例如)
'data.frame': 50 obs. of 1 variable:
$ x: Factor w/ 43 levels "$39 = Jack'n'Coke, Vodka & Pepsi, and a 24 oz. Miller Lite. Fml.",..: 10 24 33 9 13 39 9 21 6 31 ...
新更新: 我想你的方法托馬斯,這不正是我想要的,因爲在我原來的some_txt我能做到這一點
> some_txt[2]
[1] "RT @Nada_7Q: #تابعني_اتابعك\[email protected]\[email protected]_alzuhair\[email protected] \[email protected]\[email protected]\[email protected]_FAEF\[email protected]_7Q★☆★☆\[email protected]\[email protected]\[email protected]\[email protected]_06…"
> some_txt[1]
[1] "RT @CodeClue: 50 CL Pepsi is unnecessary tbh."
> some_txt[3]
[1] "I just ate all my Dad's very expensive cheese and it's supposed to be eaten slowly with a nice glass of red not a Pepsi Max"
在將stringAsFactor應用於read.csv後,它仍然打印出相同的內容,但是str()類型稍有變化。但我希望整個名單都是CHR [1:50],而不僅僅是一個。 另外它只有一個單獨的列表元素,它不像我上面的原始some_txt。 我真的希望有人能幫助我>。 <這一直讓我頭疼
查看'write.csv'的'fileEncoding'參數,在['? file'](http://stat.ethz.ch/R-manual/R-devel/library/base/html/connections.html)。 – Thomas
是否有一個fileEncoding實際上將其重新轉換爲該格式? – Napmi
仔細看看這個,輸入和輸出看起來沒有什麼不同。你所看到的有什麼不同? – Thomas