Last data update: 2014.03.03

R: Create a Data Object to Fit Individual Growth Models with...
as.GroAgeDataR Documentation

Create a Data Object to Fit Individual Growth Models with Age-Length Observations

Description

From a data.frame identify columns with data on length and age from a single sex category, two sexes, or two sexes plus unsexed individuals, and optionally include date, body weight, liver weight, and gonad weight, to create a data object with a class attribute.

Usage

as.GroAgeData(x, sex, maleskey = NULL, femaleskey = NULL, colsex = NULL,
              colage, collen, colbw = NULL, colliver = NULL, colgonad = NULL,
              coldate = NULL, lentype, unitsage, unitslen, unitsbw = NULL,
              unitsliver = NULL, unitsgonad = NULL, spec)

Arguments

x

Data.frame containing the data, where each line is an individual.

sex

Character, either "Females", "Males", "Pooled", "Both", or "Total".

maleskey

Usually a numeric key indicating whether the individual is male.

femaleskey

Usually a numeric key indicating whether the individual is female.

colsex

Integer. The column in 'x' with the sex key.

colage

Integer. The column in 'x' with the age data.

collen

Integer. The column in 'x' with the length data.

colbw

Integer. Optionally, the column in 'x' with the body weight data.

colliver

Integer. Optionally, the column in 'x' with the liver weight data.

colgonad

Integer. Optionally, the column in 'x' with the gonad weight data.

coldate

Integer. Optionally, the column in 'x' with the collection date data.

lentype

Character. In the case of fish, this indicates whether the length is total, fork, or standard.

unitsage

Character. The units of age.

unitslen

Character. The units of length.

unitsbw

Character. Optionally, the units of body weight.

unitsliver

Character. Optionally, the units of liver weight.

unitsgonad

Character. Optionally, the units of gonad weight.

spec

Character. A species identification key.

Details

When 'sex' is "Females" or "Males", the data.frame 'x' contains data for a single sex. When 'sex' is "Pooled" the sex has not been determined and both sexes might be mixed. When 'sex' is "Both" all individuals have been sexed. Finally, when 'sex' is 'Total' some individuals have been sexed but some have been not so there is a third sex category which implicitly corresponds to unsexed individuals. For instance this could happen with very young individuals for which their sex could not be determined.

Value

A list with class attribute 'GroAgeData' with the following components:

Properties

A data.frame with properties of the data, such as the species key, the type of sex, units of age, units of length, and the other optional properties

Sex 1

A data.frame with an individual key, the age, the length, and optionally other individual data

Sex 2

Optionally, the same as the previous component but for the other sex

Sex 3

Optionally, the same as the previous components but for the unsexed individuals

Note

NAs are allowed in all data column and later ignored in the modeling functions.

Author(s)

Ruben H. Roa-Ureta

Examples

data(ksbream)
KSBream.AgeLen <- as.GroAgeData(x=ksbream,
                                sex="Total",
                                maleskey=1,
                                femaleskey=2,
                                coldate=1,
                                colsex=9,
                                colage=11,
                                collen=2,
                                colbw=5,
                                colliver=7,
                                colgonad=8,
                                lentype="Total",
                                unitsage="Years",
                                unitslen="mm",
                                unitsbw="g",
                                unitsliver="g",
                                unitsgonad="g",
                                spec="KSBream")
plot(KSBream.AgeLen)

Results


R version 3.3.1 (2016-06-21) -- "Bug in Your Hair"
Copyright (C) 2016 The R Foundation for Statistical Computing
Platform: x86_64-pc-linux-gnu (64-bit)

R is free software and comes with ABSOLUTELY NO WARRANTY.
You are welcome to redistribute it under certain conditions.
Type 'license()' or 'licence()' for distribution details.

R is a collaborative project with many contributors.
Type 'contributors()' for more information and
'citation()' on how to cite R or R packages in publications.

Type 'demo()' for some demos, 'help()' for on-line help, or
'help.start()' for an HTML browser interface to help.
Type 'q()' to quit R.

> library(LifeHist)
Loading required package: Hmisc
Loading required package: lattice
Loading required package: survival
Loading required package: Formula
Loading required package: ggplot2

Attaching package: 'Hmisc'

The following objects are masked from 'package:base':

    format.pval, round.POSIXt, trunc.POSIXt, units

> png(filename="/home/ddbj/snapshot/RGM3/R_CC/result/LifeHist/as.GroAgeData.Rd_%03d_medium.png", width=480, height=480)
> ### Name: as.GroAgeData
> ### Title: Create a Data Object to Fit Individual Growth Models with
> ###   Age-Length Observations
> ### Aliases: as.GroAgeData
> ### Keywords: ~manip
> 
> ### ** Examples
> 
> data(ksbream)
> KSBream.AgeLen <- as.GroAgeData(x=ksbream,
+                                 sex="Total",
+                                 maleskey=1,
+                                 femaleskey=2,
+                                 coldate=1,
+                                 colsex=9,
+                                 colage=11,
+                                 collen=2,
+                                 colbw=5,
+                                 colliver=7,
+                                 colgonad=8,
+                                 lentype="Total",
+                                 unitsage="Years",
+                                 unitslen="mm",
+                                 unitsbw="g",
+                                 unitsliver="g",
+                                 unitsgonad="g",
+                                 spec="KSBream")
> plot(KSBream.AgeLen)
> 
> 
> 
> 
> 
> dev.off()
null device 
          1 
>