0

I want to know if there is a way to go back to my original database (df) after I have made it a document term matrix.

Here is an example of what I want to do.

df <- data.frame(group=c("A","A","B","B","C"),
                 comment = c("hello world","hello friend","one world","one friend","hello friend"))

my_cor <- tm::Corpus(VectorSource(df$comment))
my_tdm <- tm::DocumentTermMatrix(my_cor, control = list(minWordLength = 1))
final_matrix <- as.matrix(my_tdm)

I want to transform "final_matrix" to "df".

I hope someone can help me, thank you very much.

0 Answers0