Re: [R] Reading a bunch of csv files into R

2012-05-28 Thread HJ YAN
a frames in a list >> >> df.list <- lapply(seq_len(filenames), read.csv, ...) # '...other...' are >> options you might want to pass, (like headers=TRUE) >> names(df.list) <- data_names >> >> Now access the data frames by number in the list or by name in

Re: [R] Reading a bunch of csv files into R

2012-05-28 Thread Bryan Hanson
ems to replace is not a multiple of replacement length >> 4: In N[i] <- read.csv(filenames[i]) : >> number of items to replace is not a multiple of replacement length >> 5: In N[i] <- read.csv(filenames[i]) : >> number of items to replace is not a multiple of replacement

Re: [R] Reading a bunch of csv files into R

2012-05-28 Thread HJ YAN
th(filenames)) assign(data_names[i], >> read.csv(file.path(myDir, filenames[i]))) >> >> >> Benjamin Nutter | Biostatistician | Quantitative Health Sciences >> Cleveland Clinic| 9500 Euclid Ave. | Cleveland, OH 44195 | (216) >> 445-1365 >&

Re: [R] Reading a bunch of csv files into R

2012-05-28 Thread Bryan Hanson
the list or by name in data_names. > > Hope this helps, > > Rui Barradas > Em 25-05-2012 20:08, Nutter, Benjamin escreveu: > For example: > > myDir<- "some file path" > filenames<- list.files(myDir) > filenames<- filenames[grep("[.]csv",

Re: [R] Reading a bunch of csv files into R

2012-05-25 Thread Rich Shepard
On Fri, 25 May 2012, HJ YAN wrote: Is there any claver way that I do not have to type in all these hundreds names by hand, maybe using a R package or write some code in some other languages if it is not too difficult to learn. I'd put the list of commands in a shell script; e.g., # import_f

Re: [R] Reading a bunch of csv files into R

2012-05-25 Thread Rui barradas
un...@r-project.org [mailto:r-help-boun...@r-project.org] On Behalf Of Kevin Wright Sent: Friday, May 25, 2012 2:55 PM To: HJ YAN Cc: r-help@r-project.org Subject: Re: [R] Reading a bunch of csv files into R See ?dir Assign the value to a vector and loop over the elements of the vector. Kevin O

Re: [R] Reading a bunch of csv files into R

2012-05-25 Thread Nutter, Benjamin
Wright Sent: Friday, May 25, 2012 2:55 PM To: HJ YAN Cc: r-help@r-project.org Subject: Re: [R] Reading a bunch of csv files into R See ?dir Assign the value to a vector and loop over the elements of the vector. Kevin On Fri, May 25, 2012 at 12:16 PM, HJ YAN wrote: > Dear R users > > &

Re: [R] Reading a bunch of csv files into R

2012-05-25 Thread Bryan Hanson
HJ, try something like this: files <- list.files(pattern = "\\.(csv|CSV)$") for (i in 1:length(files)) { temp <- read.csv(files[i], header = FALSE) ... do whatever you want with the contents of temp... } Bryan *** Bryan Hanson Professor of Chemistry & Biochemistry

Re: [R] Reading a bunch of csv files into R

2012-05-25 Thread Kevin Wright
See ?dir Assign the value to a vector and loop over the elements of the vector. Kevin On Fri, May 25, 2012 at 12:16 PM, HJ YAN wrote: > Dear R users > > > I am struggling from a data importing issue: > > I have some hundreds of csv files needed to be read into R for futher > analysis. All thos

[R] Reading a bunch of csv files into R

2012-05-25 Thread HJ YAN
Dear R users I am struggling from a data importing issue: I have some hundreds of csv files needed to be read into R for futher analysis. All those csv files are named in one of the three formats: (1) strings: e.g. London_Oxford street (2) Integer: e.g. 1234_5678 (3) combined: e.g. London_1234