I think you might want

      names(r) <-  c("x1", "x2", "x3")

rather than

      r@layernames <- c("x1", "x2", "x3")

Jim


-----Original Message-----
From: r-sig-ecology-boun...@r-project.org 
[mailto:r-sig-ecology-boun...@r-project.org] On Behalf Of Alok K. Bohara
Sent: Thursday, December 06, 2012 10:26 AM
To: r-sig-ecology@r-project.org
Subject: [R-sig-eco] error in layernames and RasterStack

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@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

_______________________________________________
R-sig-ecology mailing list
R-sig-ecology@r-project.org
https://stat.ethz.ch/mailman/listinfo/r-sig-ecology





This electronic message contains information generated by the USDA solely for 
the intended recipients. Any unauthorized interception of this message or the 
use or disclosure of the information it contains may violate the law and 
subject the violator to civil or criminal penalties. If you believe you have 
received this message in error, please notify the sender and delete the email 
immediately.

_______________________________________________
R-sig-ecology mailing list
R-sig-ecology@r-project.org
https://stat.ethz.ch/mailman/listinfo/r-sig-ecology

Reply via email to