1

Today I learn Topic Model in R. The very first question is how to load the dataset below. I find there are some pre-built in datasets in R. But How can I save a newly built dataset in R so that I can use it as i use others like crude,acq.... How to write adtm in The data() in the following lines? And how to save adtm so that next time I can I use it like crude? Thank you very much. Can you please help me?

library(tm)
library(topicmodels)
setwd('F://_topic//economist//use//articledir') 
adataset  <-Corpus(DirSource("F://_topic//economist//use//articledir"), readerControl = list(language="lat")) 
adataset <- tm_map(adataset, removeNumbers)
adataset <- tm_map(adataset, removePunctuation)
adataset <- tm_map(adataset , stripWhitespace)
adataset <- tm_map(adataset, tolower)
adataset <- tm_map(adataset, removeWords, stopwords("english")) 
adtm <-DocumentTermMatrix(adataset) 
adtm <- removeSparseTerms(adtm, 0.75)

data(adtm, package = "topicmodels")
# error, no adtm dataset, how to write here.
best.model  <- lapply.. 
Dylan
  • 1,183
  • 4
  • 13
  • 26

0 Answers0