Richard Liu wrote:
There are actually two vignettes. Both have examples of a vector of
characters being made into a tm corpus, but neither shows how to read
documents on the file system into the vectors. I tried the other two
suggestions, but paste seemed not to glue the separate lines
kenhorvath wrote:
Dieter Menne wrote:
library(tm)
filenames = list.files(path=.,pattern=\\.txt)
docs =
for (filename in filenames){
docs = c(docs,paste(readLines(file(filename)),collapse=\n))
}
docs
## continue as in example
vs = VectorSource(docs)
If in any way
Richard Liu wrote:
I tried the other two suggestions, but paste seemed not to glue the
separate lines together into one character string. Perhaps I missed
something (collapse?). Perhaps I'll have another look.
Yes, that is what 'collapse' should do! If you read text using
Dieter Menne wrote:
While I agree that the appending could be more efficiently be done by a
list as an intermediate, the
docs = c(doc, ljljljl)
construct is not recursive, even if not efficient.
Yes, of course, that was hastily written, sorry ... but from my experience
list
Richard Liu wrote:
I'm new to R. I'm working with the text mining package tm. I have
several plain text documents in a directory, and I would like to read all
the files with extension .txt in that directory into a vector, one text
document per vector element. That is, v[1] would be the
I'm new to R. I'm working with the text mining package tm. I have several
plain text documents in a directory, and I would like to read all the files
with extension .txt in that directory into a vector, one text document per
vector element. That is, v[1] would be the first document, v[2] the
Richard Liu wrote:
I'm new to R. I'm working with the text mining package tm. I have several
plain text documents in a directory, and I would like to read all the files
with extension .txt in that directory into a vector, one text document per
vector element. That is, v[1] would be the first
Paul Hiemstra wrote:
file_list = list.files(/where/are/the/files)
obj_list = lapply(file_list, FUN = yourfunction)
yourfunction is probably either read.table or some read function from
the tm package. So obj_list will become a list of either data.frame's or
tm objects.
The
kenhorvath wrote:
Paul Hiemstra wrote:
file_list = list.files(/where/are/the/files)
obj_list = lapply(file_list, FUN = yourfunction)
yourfunction is probably either read.table or some read function from
the tm package. So obj_list will become a list of either data.frame's or
9 matches
Mail list logo