[R] regression of values in one stack with another

John Wasige johnwasige at gmail.com
Thu Apr 16 21:00:03 CEST 2015


D
​ear community,

This is to kindly request for your help.
 I have an error from regression of values in one stack with another
# s1 and s2 have 720 layers; coefficients[2] is the slope


### script
rstack1 <- stack(s1,s2)
s <- stack('D:/Correlation/rstack.tif')
fun <- function(x) { lm(x[1:360] ~ x[361:720])$coefficients[2] }
x1 <- calc(s, fun)

I get the following error:

Error in .calcTest(x[1:5], fun, na.rm, forcefun, forceapply) : cannot
use this function

Many thanks for your help in sloving this problem

John

​

	[[alternative HTML version deleted]]



More information about the R-help mailing list