[R] Speed Optimization: Faster Way of Accessing data.frame in a Loop?

Sven C. Koehler schween at snafu.de
Fri Nov 10 16:46:35 CET 2006


Hello,

currently I am using code, which basically works like this:

| 
| for (i in 1:20) {
|   for (j in 1:30) {
|     df[i, j, 20] <- df[i,j,27] + df[i,j,30]
|   }
| }

df is:  `data.frame: 360 obs. of  30 variables'

Do you have any ideas whether I could get this code any faster?

Regards,

Sven C. Koehler



More information about the R-help mailing list