Re: [R] Arithmetic on multiple files

2009-12-02 Thread Benjamin Müller
Ain't it as simple as load them ("read()" or "read.csv()"), add (+) these dataframes and thats all? you also can export them again with "write()". greets, Benjamin Müller Muhammad Rahiz schrieb: Dear R-users, I'd like to perform arithmetic functions on 1000 files containing a 2000x2000 matr

Re: [R] Arithmetic on multiple files

2009-12-02 Thread Romain Francois
About this: foo <- function( files = c( "file1", "file2" ), nr = 3, nc = 3 ){ out <- numeric( nr * nc ) for( i in seq_along(files)){ out <- out + scan( files[i] , what = numeric(0), quiet = TRUE ) } matrix( out, nr = nr, nc = nc, byrow = T ) } > foo() [,1] [,2] [,3] [1,]5

[R] Arithmetic on multiple files

2009-12-02 Thread Muhammad Rahiz
Dear R-users, I'd like to perform arithmetic functions on 1000 files containing a 2000x2000 matrix. Can anyone advise? For example, File1File2 Output 1 1 1 4 4 4 5 5 5 2 2 2 +5 5 5= 7 7 7 3 3 3 6 6 6 9 9 9 Muhamm