formatWideLong:
Convert between wide and long data formats.
Description
Convert a data.frame between wide and long formats.
Usage
formatWide(dfin, sep = ".", obsToY, type, ...)
formatLong(dfin, species = NULL, type)
Arguments
dfin
A data.frame to be reformatted.
sep
A seperator of column names in wide format.
obsToY
Optional matrix specifying relationship between covariate
column structure and response matrix structure.
type
Type of unmarkedFrame to create?
species
Character name of species response column
Details
In order for these functions to work, the columns of dfin
need to be in the
correct order. formatLong
requires that the columns are in the
following scheme:
- site name or number.
- date or observation number.
- response variable (detections, counts, etc).
- The remaining columns are observation-level covariates.
formatWide
requires particular names for the columns.
The column order for formatWide
is
- (optional) site name, named site.
- response, named y.1, y.2, ..., y.J.
- columns of site-level covariates, each with a relevant name per column.
- groups of columns of observation-level covariates, each group
having the name form someObsCov.1, someObsCov.2,
...,
someObsCov.J.