Re: [R] Average of data files in a directory

2009-07-02 Thread Peter Perez
Hi, Thanks to Henrique and Prof. Spector for their kind reply. Indeed, the mean function does work, but the result I want is an average data vector, not an scalar, which is the output of mean(). This is, given these two data frames (each data frame has 500 rows): Time Pressure 0.0 100

Re: [R] Average of data files in a directory

2009-07-02 Thread Henrique Dallazuanna
Peter, Try this: apply(do.call(merge, c(loadfiles, by = Time))[2:3], 1, mean) On Thu, Jul 2, 2009 at 10:39 AM, Peter Perez plp...@gmail.com wrote: Hi, Thanks to Henrique and Prof. Spector for their kind reply. Indeed, the mean function does work, but the result I want is an average data

Re: [R] Average of data files in a directory

2009-07-02 Thread Peter Perez
Hi Henrique, This works perfectly!. Thanks so much for your help. Best regards, Peter Henrique Dallazuanna wrote: Peter, Try this: apply(do.call(merge, c(loadfiles, by = Time))[2:3], 1, mean) On Thu, Jul 2, 2009 at 10:39 AM, Peter Perez plp...@gmail.com wrote: Hi, Thanks to

[R] Average of data files in a directory

2009-07-01 Thread plpd00
Dear all, I know it is as simple as c - (a + b)/2 to compute the average (element-wise) of two data vectors. However, I can't work out to compute the average when you have many data vectors in a directory. I have done this: setwd(/.../data/) listfiles -

Re: [R] Average of data files in a directory

2009-07-01 Thread Henrique Dallazuanna
The mean function works in data.frames: lapply(loadfiles, mean) [[1]] Time Pressure 1. 323. [[2]] Time Pressure 1. 323. On Wed, Jul 1, 2009 at 1:50 PM, plpd00 plp...@gmail.com wrote: Dear all, I know it is as simple as c - (a + b)/2 to compute the average