从 R 中的文档术语矩阵恢复原始数据
我想知道在将其制作为文档术语矩阵后是否有办法返回到我的原始数据库(df)。
这是我想做的一个例子。
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)
我想将“final_matrix”转换为“df”。
我希望有人能帮助我,非常感谢。
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.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论