Calculate trend in large raster stack in R


Staff member
I want to calculate the trend of a raster stack in R, using daily data for 50 years for the whole of Europe.

time <- 1:nlayers(gimms.sum) 
fun=function(x) { if ([1])){ NA } else { m = lm(x ~ time); summary(m)$coefficients[2] }}
gimms.slope=calc(gimms.sum, fun)

The code above was taken from here [1]. However, I get the message that the vector is 8.6 Gb and cannot allocate the memory

[1] <a href="" rel="nofollow noreferrer"></a>

How could I deal with this issue?