Learn R Programming

nexus (version 0.4.0)

as.data.frame: Coerce to a Data Frame

Description

Coerce to a Data Frame

Usage

# S4 method for CompositionMatrix
as.data.frame(x, row.names = rownames(x), optional = FALSE, ...)

# S4 method for GroupedComposition as.data.frame( x, row.names = rownames(x), optional = FALSE, ..., group_var = ".group" )

# S4 method for LogRatio as.data.frame(x, row.names = rownames(x), optional = FALSE, ...)

# S4 method for GroupedLogRatio as.data.frame( x, row.names = rownames(x), optional = FALSE, ..., group_var = ".group" )

# S4 method for OutlierIndex as.data.frame(x, row.names = rownames(x), optional = FALSE, ...)

Value

A data.frame.

Arguments

x

An R object (typically, a CompositionMatrix object).

row.names

A character vector giving the row names for the data frame, or NULL.

optional

A logical scalar: should the names of the variables in the data frame be checked? If FALSE then the names of the variables in the data frame are checked to ensure that they are syntactically valid variable names and are not duplicated.

...

Currently not used.

group_var

A character string specifying the name of the column to create for group attribution.

Author

N. Frerebeau

See Also

Other mutators: mutators, totals()

Examples

Run this code
## Create a count matrix
A1 <- matrix(data = sample(1:100, 100, TRUE), nrow = 20)

## Coerce to compositions
B <- as_composition(A1)

## Row sums are internally stored before coercing to relative frequencies
totals(B)

## This allows to restore the source data
A2 <- as_amounts(B)

## Coerce to a data.frame
X <- as.data.frame(B)
head(X)

Run the code above in your browser using DataLab