Q:

R Raster package loop over pixels

I want to perform a trend analysis for each pixel over it's time dimension.
Therefore I wrote a loop over each pixel doing the calculation but this is extremely slow.
I am sure there must be a faster way to perform the computation.
Also the dimensions of the file are 1440,720,480. 
Is this a doable size for R? The problem is that i cannot find the statistical function implemented in IDL which I otherwise use.
gridfile = 'test.nc'
data = brick(gridfile)

require(fume)

mk = matrix(numeric(0), 720,1440) 

for(i in 1:72) {
  for(j in 1:144) {
  temp = mkTrend(as.vector(data[i,j,]))
  mk[i,j] = temp$`Sen's Slope`
  }
}

A:

Package raster provides a function calc that executes a function over all raster pixels, returning the raster with results; it can deal with large rasters (out-of-memory). raster also provides cluster/multi-core functionality, look into function beginCluster; it's meant to work with calc.

