stcs: Create an Object of Class 'stcs'

Description Usage Arguments Details Value Note Author(s) References See Also Examples

Description

This function creates object of class 'stcs' from a data frame. This is the primary format for long (database style) data sets in the mefa package. The 'stcs' object can be converted into an object of class 'mefa' with the function mefa. The function name 'stcs' refers to first letters of column names of the resulting object: samples, taxa, counts, segments.

Usage

1
2
3
4
5
stcs(dframe, expand = FALSE, drop.zero = FALSE, zero.pseudo = "zero.pseudo")
## S3 method for class 'stcs'
is(x)
## S3 method for class 'stcs'
summary(object, ...)

Arguments

dframe

a data frame with 2-4 columns. If 2 columns are provided, it is assumed that first column contains sample, while second taxa names. If 3 columns are provided, the first two is treated as sample and taxa names, while the third is treated as count if numeric (either integer or non-integer values can be supplied), and segment if character or factor. If 4 columns are provided, those are assumed to be in the samples, taxa, count, segment order.

expand

logical, whether the object should be (TRUE) expanded (via the function rep.data.frame) or not (FALSE, default). If expanded, each rows correspond to one individual observation (value of the count column is 1) or a zero sample. expand = TRUE works only with integer values.

drop.zero

logical, whether samples with zero total count should be left out (TRUE) or not (FALSE, default).

zero.pseudo

character, value in the taxa column that indicates zero samples. If it is a vector of length 2, first element is used for taxa names, second for segment names to indicate zero samples.

x, object

an object of class 'stcs'.

...

further arguments passed to the function stcs.

Details

If the data are in a long (database style) format, the stcs function prepares the ground for the mefa function to make the cross tabulation. But if only a crosstabulated matrix is needed, the table function can be applies as well (in this case be sure to set expand = TRUE, and this is only for integer data), or alternatively see the xtabs or mefaCrosstab functions (these accepts non-integer data). For subsetting, simply use extraction methods available for data frames ([.data.frame).

The summary contains statistics calculated after coercing the object into the class 'mefa'.

Methods for extracting, subsetting are the same as for data frame objects. Plotting 'stcs' objects are discussed elsewhere (see links in 'See also' section).

Value

Returns an object of class 'stcs' with 4 columns. The column names are converted consistently into samp for samples, taxa for taxa names, count for counts and segm for segment names.

The class has its own methods (i.e. is, as.stcs, summary and plot), but also has a data.frame class attribute. Thus other methods that available for data frames are applicable to an object of class 'stcs' (e.g. print, str).

Note

The stcs function nearly equivalent to the sscount function in older (< 2.0) versions of the mefa package.

Author(s)

P\'eter S\'olymos, solymos@ualberta.ca

References

S\'olymos P. (2008) mefa: an R package for handling and reporting count data. Community Ecology 9, 125–127.

S\'olymos P. (2009) Processing ecological data in R with the mefa package. Journal of Statistical Software 29(8), 1–28. doi: 10.18637/jss.v029.i08

http://mefa.r-forge.r-project.org/

See Also

data.frame, summary.data.frame, str, table

See plot.stcs boxplot.stcs and image.stcs for graphical display options.

See as.stcs for coercion methods.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
## General long format data
x <- data.frame(
    sample = paste("Sample", c(1,1,2,2,3,4), sep="."),
    species = c(paste("Species", c(1,1,1,2,3), sep="."),  "zero.pseudo"),
    count = c(1,2,10,3,4,0),
    segment = letters[c(6,13,6,13,6,6)])
x
## Long format as stcs
y <- stcs(x)
y
## Methods
as.stcs(x)
is(y, "stcs")
is(y, "data.frame")
## Effects of arguments
stcs(x, expand = TRUE)
stcs(x, drop.zero = TRUE)
stcs(x, zero.pseudo = "pseudo.secies")
## Input options
stcs(x[,1:2])
stcs(x[,1:3])
stcs(x[,c(1:2,4)])
## The Dolina dataset
data(dol.count)
dol <- stcs(dol.count)
dol
plot(dol)

psolymos/mefa documentation built on Oct. 10, 2021, 6:22 p.m.