Converts between types of measurements from calcified structures.

Share:

Description

Converts wide format growth data from radial to incremental or incremental to radial measurements.

Usage

1
2
gConvert(df, in.pre = NULL, in.var = NULL, out.type = c("inc", "rad"),
  out.pre = out.type)

Arguments

df

A data.frame that contains the growth measurement data in wide or one-fish-per-line format.

in.pre

A string that indicates the prefix for all variable names in the input data frame that contain the measurements from the calcified structures. See details.

in.var

A vector of column numbers or variable names in the input data frame that contain the measurements from the calcified structures. See details.

out.type

A string that identifies the output format data type (i.e., the format to convert to). If "inc} (the default) the output data frame will be incremental measurements. If \code{"rad the output data frame will be radial measurements.

out.pre

A string that indicates the prefix to use for the newly computed measurements in the output data frame. Defaults to the same string as out.type.

Details

The data must be in WIDE format where each row contains all information (including all measurements from the calcified structure) for an individual fish. It is assumed that the input data.frame is of the opposite data type given in out.type (i.e., that a conversion is needed). It does not check to see if this is true.

The columns that contain the original measurement data can specified in a variety of ways. First, if all columns begin with the same prefix (and no other columns contain that prefix), then the prefix string may be given to in.pre=. Second, a sequence of column numbers may be given to in.var= with the #:# (if the columns are contiguous) or as a vector (if the columns are not contiguous). Third, a vector of column names may be given to in.var=. Note that one, but not both, of in.var= or in.pre= must be specified by the user.

The newly computed data will be labeled with a prefix the same as out.type= (i.e., "rad" or "inc") unless out.pre= is set by the user. For example, if the data are converted to radial measurements, then the output variables will be “rad1”, “rad2”, etc. unless out.pre= was changed from the default. This function assumes that the measurements start with age-1.

Value

A data.frame with all columns, except for those defined by in.pre or in.var, from the df retained as the left-most columns and the original data in the in.var columns converted to the out.type type as the remaining columns.

Author(s)

Derek H. Ogle, derek@derekogle.com

See Also

See addRadCap for related functionality.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
## Get data with radial measurements
data(SMBassWB)
headtail(SMBassWB)

## Use in.pre= to convert to increments
SMBi1 <- gConvert(SMBassWB,in.pre="anu",out.type="inc")
headtail(SMBi1)

## Use in.var= with column names to convert to increments
SMBi2 <- gConvert(SMBassWB,in.var=c("anu1","anu2","anu3","anu4","anu5","anu6",
                                    "anu7","anu8","anu9","anu10","anu11","anu12"),
                           out.type="inc")
headtail(SMBi2)

## Use in.var with column numbers to convert to increments
SMBi3 <- gConvert(SMBassWB,in.var=8:19,out.type="inc")
headtail(SMBi3)

## Convert back to radial measurements
SMBr1 <- gConvert(SMBi1,in.pre="inc",out.type="rad")
headtail(SMBr1)

Want to suggest features or report bugs for rdrr.io? Use the GitHub issue tracker.