1 year ago
#240095
![test-img](https://lh6.googleusercontent.com/-MLNzxURxdyI/AAAAAAAAAAI/AAAAAAAAB2Q/-9uk6I1SA0w/photo.jpg?sz=256)
Sergio Parra
Restore original data from document term matrix in R
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.
r
matrix
tm
tidytext
0 Answers
Your Answer