Twitterのハッシュタグを収集しています。それぞれのツイートはハッシュタグを含むことができます。data.frameオブジェクトにハッシュタグを分割するR
tests <- c("xxxxxx #SaveTheDate xxxxxx #Histoire] xxxxxx #Femmes xxxxxxx #ports",
"xxxxxxxxxxxx",
"xxxx #rock xxxxxx #Nantes" ,
"xxxxxx #lvan xxxxxxx #nantes xxxxx #ilsepassetoujoursuntruc")
library (stringr)
hashtags <- str_extract_all(tests, "#\\S+")
str (hashtags)
馬結果:
str(hashtags)
list of 4
$ : chr [1:4] "#SaveTheDate" "#Histoire]" "#Femmes" "#ports"
$ : chr(0)
$ : chr [1:2] "#rock" "#Nantes"
$ : chr [1:3] "#lvan" "#nantes" "#ilsepassetoujoursuntruc"
私は何を期待:行に対して1つのハッシュタグとdata.frame
"#SaveTheDate"
"#Histoire"
"#Femmes"
"#ports"
NA
....
Iが試み何:
hashtags_df <-as.data.frame(hashtags)
'as.data.frame()'があなたの意図をどのように神聖にしていたのでしょうか? [this](http://stackoverflow.com/questions/38788494/hashtag-extract-function-in-r-programming/38789142#38789142)は、ハッシュタグの認識と抽出に役立ちます。私はあなたがハッシュタグスパム、ハッシュタグ汚染、ハッシュタグ乱用にどう対処するのか不思議です。あなたのコーパスの20〜30%がそれらのものに詰め込まれます。 – hrbrmstr
私はそれに取り組んでいます。 – Wilcar