I have taken generic text of 1000 rows and performed the below in the process of textmining. While using the document Term matrix I am not getting the count of words as output in the matrix.
>def<-read.csv("Defect.csv",header = T)
>docs<-Corpus(VectorSource(def$Summary))
>docs<-tm_map(docs,content_transformer(tolower))
>docs<-tm_map(docs,removeNumbers)
>docs<-tm_map(docs,removeWords,stopwords("english"))
>docs<-tm_map(docs,removePunctuation)
>docs<-tm_map(docs,stripWhitespace)
>docs<-tm_map(docs,stemDocument,language = "english")
>docs[[1]]$content
[1] "access logout access employe separ modul"
>dtm<-DocumentTermMatrix(docs)
>data.matrix(dtm)
Below is the output I got for DTM
Terms Docs access logout modul separ approv button click display error
I am not getting the word count in a matrix. Not sure of what could be the error here.
m <- as.matrix(dtm); sort(rowSums(m), decreasing = TRUE)to get your desired output - parth