word cloud - R wordcloud-finding frequency per block of text -


this question has answer here:

i have csv file of data contain phrases :

dd<-c("hello how you?";"i fine"; "hello how you?"; "not bad") 

i want frequency of each block of sentences (divided ;) using wordcloud. however, frequency per word.

is there way frequency per block of content in each cell?

in toy example get:

text                   freq  ---------------------------- hello how you?     2  fine              1  not bad            1 

thank in advance

fwiw, try this

library(wordcloud) library(tm) txt <- c("hello how you? fine", "hello how you?; not bad") semicolontonekizer <- function(x) unlist(strsplit(as.character(x), ";", fixed = true)) tdm <- termdocumentmatrix(corpus(vectorsource(txt)), list(tokenize = semicolontonekizer)) tab <- rowsums(as.matrix(tdm)) wordcloud(names(tab), tab) 

Comments

Popular posts from this blog

php - failed to open stream: HTTP request failed! HTTP/1.0 400 Bad Request -

java - How to filter a backspace keyboard input -

java - Show Soft Keyboard when EditText Appears -