occumbData {occumb} | R Documentation |
Constructor for occumbData data class.
Description
occumbData()
creates a data list compatible with the model fitting
function occumb()
.
Usage
occumbData(y, spec_cov = NULL, site_cov = NULL, repl_cov = NULL)
Arguments
y |
A 3-D array of sequence read counts ( |
spec_cov |
A named list of species covariates.
Each covariate can be a vector of continuous ( |
site_cov |
A named list of site covariates.
Each covariate can be a vector of continuous ( |
repl_cov |
A named list of replicate covariates.
Each covariate can be a matrix of continuous ( |
Details
The element (i.e., covariate) names for spec_cov
, site_cov
, and
repl_cov
must all be unique.
If y
has a dimnames
attribute, it is retained in the resulting
occumbData
object, and can be referenced in subsequent analyses.
Value
An S4 object of the occumbData
class.
Examples
# Generate the smallest random dataset (2 species * 2 sites * 2 reps)
I <- 2 # Number of species
J <- 2 # Number of sites
K <- 2 # Number of replicates
data <- occumbData(
y = array(sample.int(I * J * K), dim = c(I, J, K)),
spec_cov = list(cov1 = rnorm(I)),
site_cov = list(cov2 = rnorm(J), cov3 = factor(1:J)),
repl_cov = list(cov4 = matrix(rnorm(J * K), J, K))
)
# A case for named y (with species and site names)
y_named <- array(sample.int(I * J * K), dim = c(I, J, K))
dimnames(y_named) <- list(c("common species", "uncommon species"),
c("good site", "bad site"), NULL)
data_named <- occumbData(
y = y_named,
spec_cov = list(cov1 = rnorm(I)),
site_cov = list(cov2 = rnorm(J), cov3 = factor(1:J)),
repl_cov = list(cov4 = matrix(rnorm(J * K), J, K))
)
# A real data example
data(fish_raw)
fish <- occumbData(
y = fish_raw$y,
spec_cov = list(mismatch = fish_raw$mismatch),
site_cov = list(riverbank = fish_raw$riverbank)
)
# Get an overview of the datasets
summary(data)
summary(data_named)
summary(fish)