I am fairly new to R and trying to model occupancy probability for my species (Lepilemur). I have 21 sites, 2 site covariates and 3 observation covariates. My code is as follows:
lepi<-read.csv("Lepilemur2.csv", header=T)
nSites<- 21
lepiDetects<- lepi[,2:4]
lepiSiteCovars<-as.data.frame(lepi[,5:6])
lepiObsCovars<-as.data.frame(lepi[,7:9])
detect<-apply(lepiDetects, 2, function(x){as.numeric(as.character(x))})
umf<-unmarkedFrameOccu(y=detect, siteCovs= lepiSiteCovars, obsCovs=lepiObsCovars)
However when I run the final line of code i receive the following error: Error in validObject(.Object) : invalid class “unmarkedFrame” object: obsCovData does not have M*obsNum rows
In my global environment it says I have 21 observations of 3 variables.
Any help you can offer me would be hugely appreciated.
Thanks,
Buffy
For your case, I would do
Details about why that will work are as follows. The manual for unmarkedFrameOccu states you can use a data frame but there's something weird about it:
I tested it using the example from the library
unmarked
, we simulate some data:The example from the vignette works, using a list:
But if we do something similar to your example, we get the error:
So we have to do: