unfactor {dmm} | R Documentation |
Convert a vector (such as a dataframe column) from factor to numeric. Non-numeric values will coerce to NA.
unfactor(x)
x |
A vector of type factor. Typically this would be one column of a dataframe. |
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.
A vector of numeric values is returned.
Neville Jackson
Functions dmm()
, read.table()
library(dmm)
tmp <- as.factor(c(1,2,3))
str(tmp)
utmp <- unfactor(tmp)
str(utmp)
rm(tmp)
rm(utmp)