I am working on a project. I would like to summarize it with similar case. I need to collect n number of tweets with different hastags.
Here is similar code:
library(tm)
#tweets from first hastag
tweets_set1 <- search_tweets("barcelona", n = 100, include_rts = FALSE)
tweets_set1$text
corpus1 <- VCorpus(VectorSource(tweets_set1$text))
corpus1
#tweets from second hashtag
tweets_set2 <- search_tweets("realmadrid", n = 100, include_rts = FALSE)
tweets_set2$text
corpus2 <- VCorpus(VectorSource(tweets_set2$text))
corpus2
#Then I need to merge all two data
merge.corpus <- c(corpus1, corpus2)
#Then I did pre-processing such as lowercases, remove punctuation, remove numbers, remove whitespace.
# Output
inspect(merge.corpus[1:50])
<<VCorpus>>
Metadata: corpus specific: 0, document level (indexed): 0
Content: documents: 51
[[1]]
<<PlainTextDocument>>
Metadata: 7
Content: chars: 41
[[2]]
<<PlainTextDocument>>
Metadata: 7
Content: chars: 59
#Question: I need to create a target variable to see whether the text belongs to hashtag 1 or 2. Any idea? Note: I can't convert it to data frame to do it