Learn R Programming

vegtable (version 0.1.3)

transform: Convert cover scales to percent cover.

Description

Convert values of a categorical cover scale to percentage values.

Usage

# S4 method for character,coverconvert
transform(x, conversion, from=NULL,
	rule="top", zeroto=0.1, ...)

# S4 method for factor,coverconvert transform(x, conversion, ...)

# S4 method for vegtable,missing transform(x, to, replace=FALSE, rule="top", zeroto=0.1, ...)

Arguments

x

Either a factor or character vector, or a '>vegtable object.

conversion

An object of class '>coverconvert.

from

Scale name of values in 'x' as character value.

to

Name of the column in slot 'samples' for writing converted values.

replace

Logical value indicating whether existing cover values should be replaced or not.

rule

Rule applied for the conversion (see details).

zeroto

Value used to replace levels with bottom at 0% cover.

...

Further arguments passed from or to other methods.

Value

Either a vector or a '>vegtable object.

Details

This function requires as input a '>coverconvert object which contains the conversion tables.

In the case of '>vegtable objects, the conversion is already embedded in the slot 'coverconvert'.

Three rules are implemented for transformation, either 'top' (values transformed to the top of the range), 'middle' (transformation at the midpoint), and 'bottom' (conversion at the lowest value of the range). In the later case, transformation ranges starting at 0% of cover can be set to a different value by the argument 'zeroto'.

When 'replace=FALSE', existing values of cover in the '>vegtable object will be maintained. Since there is not a standard naming of cover values, in the transformation the name of cover variable should be indicated in the argument 'to'.

Examples

Run this code
# NOT RUN {
library(vegtable)
data(Kenya_veg)

## Check the available scales
summary(Kenya_veg@coverconvert)

## Conversion by default 'top' rule
Kenya_veg <- transform(Kenya_veg, to="percent")
summary(as.factor(Kenya_veg@samples$percent))

## Conversion by 'middle' rule
Kenya_veg <- transform(Kenya_veg, to="percent", rule="middle", replace=TRUE)
summary(as.factor(Kenya_veg@samples$percent))

## Conversion by 'bottom' rule
Kenya_veg <- transform(Kenya_veg, to="percent", rule="bottom", replace=TRUE)
summary(as.factor(Kenya_veg@samples$percent))
# }

Run the code above in your browser using DataLab