Convert to factor, like model

Share:

Description

Convert factor-like entries in a data structure to factor, with factor as in factormodel.

Usage

1
asfactormodel(x, factormodel)

Arguments

x

A data structure. Currently only integer vectors or lists of vectors are supported.

factormodel

A data structure to serve as model for the factor specification. Currently, a factor or a vector of type character.

Value

a data structure of same type as x, with numeric vectors converted to factors.

Note

This functionality could go to R base function factor.

Should be extended to cover a wide range of data structures, and identify substructures for conversion.

Author(s)

G√ľnther Sawitzki <gsawitzki@users.r-forge.r-project.org>

Examples

1
2
3
4
5
6
	data(sprof01lm)
	
xf <- asfactormodel(sprof01lm$stacks$nodes, sprof01lm$nodes$name)

# To get a character listing, use
sapply(xf, function (x) {as.character(x)} )

Want to suggest features or report bugs for rdrr.io? Use the GitHub issue tracker.