R text mining documents from CSV file (one row per doc)

前端 未结 2 1209
梦如初夏
梦如初夏 2020-12-13 22:40

I am trying to work with the tm package in R, and have a CSV file of customer feedback with each line being a different instance of feedback. I want to import all the conten

相关标签:
2条回答
  • 2020-12-13 23:00

    Here's a complete workflow to get what you want:

    # change this file location to suit your machine
    file_loc <- "C:\\Documents and Settings\\Administrator\\Desktop\\Book1.csv"
    # change TRUE to FALSE if you have no column headings in the CSV
    x <- read.csv(file_loc, header = TRUE)
    require(tm)
    corp <- Corpus(DataframeSource(x))
    dtm <- DocumentTermMatrix(corp)
    

    In the dtm object each row will be a doc, or a line of your original CSV file. Each column will be a word.

    0 讨论(0)
  • 2020-12-13 23:12

    You can use TermDocumentMatrix() on your fdbk object, and obtain a term document matrix where each row represent a customer feedback.

    0 讨论(0)
提交回复
热议问题