unfactor {dmm}R Documentation

Convert a vector from factor to numeric

Description

Convert a vector (such as a dataframe column) from factor to numeric. Non-numeric values will coerce to NA.

Usage

unfactor(x)

Arguments

x

A vector of type factor. Typically this would be one column of a dataframe.

Details

This function may be useful when preparing a dataframe for dmm(). It is a common problem for dataframe columns to be automatically made type factor when constructing the dataframe with functions such as read.table, due to the presence of a small number of non-numeric values. Dataframe columns used as traits or as covariates should not be of type factor.

Value

A vector of numeric values is returned.

Author(s)

Neville Jackson

See Also

Functions dmm(), read.table()

Examples


library(dmm)
tmp <- as.factor(c(1,2,3))
str(tmp)
utmp <- unfactor(tmp)
str(utmp)
rm(tmp)
rm(utmp)

[Package dmm version 2.1-9 Index]