Re: [R] Reading in files with variable parts to names

2009-03-27 Thread Steve Murray
Thanks, that's great - just what I was looking for. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-conta

Re: [R] Reading in files with variable parts to names

2009-03-27 Thread Romain Francois
That's because do.call wants a list: what about this one: > do.call( sprintf, append( list("C:\\Documents and Settings\\Data\\comp_runoff_hd_%04d%02d.asc"), expand.grid( seq(1986,1995), 1:12) ) ) Romain Steve Murray wrote: Dear all, Thanks for the help in the previous posts. I've conside

Re: [R] Reading in files with variable parts to names

2009-03-27 Thread jim holtman
Does this give you what you want (just did it in two steps); > x <- expand.grid(year = sprintf("%04d", seq(1986, 1995)), month = > sprintf("%02d", 1:12)) > filelist <- paste("C:\\Documents and Settings\\Data\\comp_runoff_hd_", > paste(x$year, x$month, sep=''), '.asc', sep='') > > > > > filelist

Re: [R] Reading in files with variable parts to names

2009-03-27 Thread Steve Murray
Dear all, Thanks for the help in the previous posts. I've considered each one and have nearly managed to get it working. The structure of the filelist being produced is correct, except for a single space which I can't seem to eradicate! This is my amended code, followed by the first twelve row

Re: [R] Reading in files with variable parts to names

2009-03-26 Thread Jorge Ivan Velez
Dear Steve, Another option would be using list() to storage your files into R: # Year/Month year <- 1986:1995 month <- sprintf("%02d", 1:12) # Names Files <- paste(year,month,'.asc',sep="") # Data ListFiles <- sapply(Files, read.table, header=TRUE,sep="") # To access the fist file ListFiles[[1

Re: [R] Reading in files with variable parts to names

2009-03-26 Thread Dieter Menne
Steve Murray hotmail.com> writes: > I'm trying to read in a whole directory of files which have two variable > parts to the file name: year and month. E.g. comp198604.asc represents < April of 1986 - 'comp' is fixed in each case. Years range between > 1986 to 1995 and months are between 1 and

Re: [R] Reading in files with variable parts to names

2009-03-26 Thread Rowe, Brian Lee Yung (Portfolio Analytics)
26, 2009 2:40 PM To: r-help@r-project.org Subject: [R] Reading in files with variable parts to names Dear all, I'm trying to read in a whole directory of files which have two variable parts to the file name: year and month. E.g. comp198604.asc represents April of 1986 - 'comp'

Re: [R] Reading in files with variable parts to names

2009-03-26 Thread baptiste auguie
Hi, If your directory contains only files you want to load anyway, then list.files() is your friend, list.files(pattern = "comp") # or pattern =".asc" for example If you do need to create the names manually, then you could create the combinations with expand.grid, as in, do.call(paste

[R] Reading in files with variable parts to names

2009-03-26 Thread Steve Murray
Dear all, I'm trying to read in a whole directory of files which have two variable parts to the file name: year and month. E.g. comp198604.asc represents April of 1986 - 'comp' is fixed in each case. Years range between 1986 to 1995 and months are between 1 and 12. Just to be clear, there are