# Fake data
M <- 4 # Number of sites
J <- 3 # Number of observation periods
# Count data
(y <- matrix(
c(1, 3, 0,
0, 0, 0,
2, 0, 5,
1, NA, 0),
nrow = M,
ncol = J,
byrow = TRUE
))
# Length of observation periods
(L <- matrix(
c(1, 3, NA,
2, 2, 2,
1, 2, 1,
7, 1, 3),
nrow = M,
ncol = J,
byrow = TRUE
))
# Site covariates
(site.covs <- data.frame(
"elev" = rexp(4),
"habitat" = factor(c("forest", "forest", "grassland", "grassland"))
))
# Observation covariates (as a list)
(obs.covs.list <- list(
"rain" = matrix(rexp(M * J), nrow = M, ncol = J),
"wind" = matrix(
sample(letters[1:3], replace = TRUE, size = M * J),
nrow = M, ncol = J)
))
# Organise data in a unmarkedFrameOccuCOP object
umf <- unmarkedFrameOccuCOP(
y = y,
L = L,
siteCovs = site.covs,
obsCovs = obs.covs.list
)
# Extract L
getL(umf)
# Look at data
print(umf) # Print the whole data set
print(umf[1, 2]) # Print the data of the 1st site, 2nd observation
summary(umf) # Summarise the data set
plot(umf) # Plot the count of detection events
# L is optional, if absent, it will be replaced by a MxJ matrix of 1
unmarkedFrameOccuCOP(
y = y,
siteCovs = site.covs,
obsCovs = obs.covs.list
)
# Covariates are optional
unmarkedFrameOccuCOP(y = y)
Run the code above in your browser using DataLab