sep.data {CTFS} | R Documentation

## Re-structures a Dataframe into a List of Dataframes by Values in a Vector

### Description

Creates a list from a dataframe of tree data using a vector with values for each tree as the names for the list. There are as many dataframes in the list as there are valid values in the vector. The values in the vector can be derived from a variable in the original dataframe or from other information about the trees. Rows with NA for the separation variable can be included or excluded.

### Usage

    sep.data(census1, sepcol = "sp", handle.na = NA)
    sep.vct.data(census1, sepvct, handle.na = NA)

### Arguments

`census1` | name of census datafile, must be a dataframe
`sepcol` | column in datafile with values that will form the components of the list. This must be a column in `census1` and must be the column name.
`sepvct` | vector of values that will form the components of the list. Must be of same length as `census1`. The vector must be created before using this function.
`handle.na` | instructions on how to handle `NA`. If `TRUE`, missing values in the data are put last; if `FALSE`, they are put first; if `NA`, they are removed.

### Details

The values of the `sepcol` and `sepvct` are sorted alphabetically and missing values are treated according to `handle.na`.

These functions are very useful for turning any dataframe into a list consisting of the same records and restructured so that each component of the list is a value of the variables in `sepcol` or in `sepvct`.

For instance, taking the tst.bci90.full dataset and creating the tst.bci90.spp dataset can be done using the defaults of `sep.data`.

`sep.vct.data` can make the same list structure based on a variable NOT found in `census1`. `sep.vct.data` uses a vector of values which is the length as the number of rows in `census1`. This vector can be created from any other source of information about the trees eg. the quadrate in which they are located.

The functions `sep.dbh`, `sep.quadinfo` and `sep.sppinfo` can be used to make vectors from the dbh of a tree, variables in the species information and quadrate information files, respectively.

Both functions send a message to the terminal to indicate which value of the `sepcol` or `sepvct` is currently being processed.

### Value

Returns a list of dataframes each of which contain tree records. The values of `sepcol` or `sepvct` are the names of the list components. However, the values of `sepcol` are returned in the dataframes as this variable is a part of `census1`. The values for `sepvct` are NOT returned in the dataframe because they are not in `census1`.

### Author(s)

Pamela Hall

### See Also

`CTFS.readwrite`

### Examples

    ## Not run:
    1. default use
    tst.out <- sep.data(tst.bci90.full)
    names(tst.out)

    2. separate data by status
    tst.out <- sep.data(tst.bci90.full,sepcol="status")
    names(tst.out)

    3. separate data by status including the NAs as the last component in
    the list
    tst.out <- sep.date(tst.bci90.full,sepcol="status",handle.na=TRUE)
    names(tst.out)

    4. separate date by quadrate (which is useful for neighborhood
    analysis), leave NAs out of the list

    quad.vct <- sep.quadinfo(tst.bci90.full,bciquad.info,by.col="quad")
    tst.vct.out <- sep.data.vct(tst.bci90.full,quad.vct)
    names(tst.vct.out)
    ## End(Not run)

[Package CTFS version 1.00 Index]