Convert a data.frame between wide and long formats.

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

...

Further arguments to the unmarkedFrame* constructor functions

Details

Note that not all possible unmarkedFrame* classes have been tested with these functions. Multinomial data sets (e.g., removal, double-observer, capture-recapture) are almost certainly easier to enter directly to the constructor function and are not supported by formatLong or formatWide.

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:

  1. site name or number.

  2. date or observation number.

  3. response variable (detections, counts, etc).

  4. The remaining columns are observation-level covariates.

formatWide requires particular names for the columns. The column order for formatWide is

  1. (optional) site name, named “site”.

  2. response, named “y.1”, “y.2”, ..., “y.J”.

  3. columns of site-level covariates, each with a relevant name per column.

  4. groups of columns of observation-level covariates, each group having the name form “someObsCov.1”, “someObsCov.2”, ..., “someObsCov.J”.

Value

A data.frame

See also