Skip to content
Prev 300968 / 398503 Next

help building dataset

Weren't you told to take a look at read.table() (both the function
help and the manual describing it)?

If the rows correspond in each data file, something like

do.call(cbind, lapply(dir(), read.table))

will possibly align the results of read.table()-ing each file in your
directory.

To parse that further:

dir() gives a list of all files in the directory.

lapply( x, FUN) takes a set of values (x) and does FUN to them. Here
it would read.table() on each file name.

do.call(cbind, x) will call the cbind() function on the results of
lapply(). It's sort of like doing cbind(x[1], x[2], x[3], ...) but
doesn't require as much typing or you to know how many columns are
going in.

Michael
On Mon, Jul 23, 2012 at 1:32 PM, walcotteric <walcott3 at msu.edu> wrote: