I used the rvest
package to download comments from a news portal and saved them using write.csv2
function. It looks that:
> str(mydata)
chr [1:300, 1:7] "~my" "~cos :" ...
- attr(*, "dimnames")=List of 2
..$ : NULL
..$ : chr [1:7] "Author" "Comment" "Time" "NumberOfVotes" ...
My aim is to prepare data for text mining, in fact for a word cloud. So at that moment I'm interested only in the "Comment" column. I tried to extract it from a file by mydata$Comment
command:
data1 <- paste(mydata$Comment, collapse= " ")
I got response:
Error in mydata$Comment : $ operator is invalid for atomic vectors.
What should I do in order to transform it into a recursive form?
Your data is in a matrix. Data.frame (or list) subsetting doesn't work for this. Use matrix subsetting, e.g., mydata[, "Comment"]
. You should study help("[")
.
You could also turn your matrix into a data.frame using as.data.frame(mydata)
.