[R] How to read plain text documents into a vector?
kenhorvath
kenneth.horvath at univie.ac.at
Tue Oct 13 12:35:35 CEST 2009
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 read function that most probably should be adequate is readLines(), so
the command would read:
obj_list <- lapply(file_list,readLines)
To convert to a vector, do the following:
obj_list <- lapply(obj_list,paste,collapse=" ")
obj_vec <- as.vector(obj_list)
Ken
--
View this message in context: http://www.nabble.com/How-to-read-plain-text-documents-into-a-vector--tp25867792p25870485.html
Sent from the R help mailing list archive at Nabble.com.
More information about the R-help
mailing list