Learn R Programming

stm (version 1.0.0)

writeLdac: Write a .ldac file

Description

A function for writing documents out to a .ldac formated file.

Usage

writeLdac(documents, file, zeroindex=TRUE)

Arguments

documents
A documents object to be written out to a file. Object must be a list of with each element corresponding to a document. Each document is represented as an integer matrix with two rows, and columns equal to the number of unique vocabulary words in the d
file
A character string giving the name of the file to be written. This object is passed directly to the argument con in writeLines and thus can be a connection object as well.
zeroindex
logical. If TRUE (the default) it subtracts one from each index. If FALSE it uses the indices as given. The standard .ldac format indexes from 0 as per standard convention in most languages. Our documents format

Details

This is a simple convenience function for writing out document corpora. Files can be read back into R using readCorpus or simply used for other programs. The output is a file in the .ldac sparse matrix format popularized by Dave Blei's C code for LDA.

See Also

readCorpus

Examples

Run this code
#Convert the gadarian data into documents format
temp<-textProcessor(documents=gadarian$open.ended.response,metadata=gadarian)
documents <- temp$documents
#Now write out to an ldac file
writeLdac(documents, file="gadarian.ldac")

Run the code above in your browser using DataLab