[R-sig-eco] error in layernames and RasterStack
Alok K. Bohara
bohara at unm.edu
Thu Dec 6 19:25:59 CET 2012
Hi: I am trying to replicate some commands in maxlike.
#***
library(raster)
set.seed(131)
x1 <- sort(rnorm(100))
x1 <- raster(outer(x1, x1), xmn=0, xmx=100, ymn=0, ymx=100)
x2 <- raster(matrix(runif(1e4), 100, 100), 0, 100, 0, 100)
x3 <- raster(matrix(c(0,1), 100, 100), 0, 100, 0, 100)
r <- stack(x1, x2, x3)
r at layernames <- c("x1", "x2", "x3")
#****
Error #1: After the last line, I get an Error:
Error in checkSlotAssignment(object, name, value) :
‘layernames’ is not a slot in class “RasterStack”
>
Error # 2: Later, I also get an error:
In addition: Warning message:
> fm2 <- maxlike(~x1 + x2 + x3, r, xy)
Error in maxlike(~x1 + x2 + x3, r, xy) :
at least 1 covariate in the formula is not in rasters.
In layerNames(rasters) :
the layerNames function is obsolete. Use "names" instead
I am using R 2.15.2. I do not know if the error #2 is the result of the error #1. Thanks.
Best,
Alok K. Bohara,
UNM
More information about the R-sig-ecology
mailing list