matrix2raw {pheno} | R Documentation |
Converts numeric matrix to data frame
Description
Converts a numeric matrix M into a dataframe D with three columns (x, factor 1, factor 2) where rows of M are ranks of factor 1 levels and columns of M are ranks of factor 2 levels, missing values are assumed to be 0 or NA. The resulting dataframe D has no missing values.
Usage
matrix2raw(M,l1,l2)
Arguments
M |
Numeric matrix, with missing values assumed to be NA or 0. |
l1 |
Optional numeric vector of level names of column 2 (factor 1)
of returned data frame. If missing it is assigned row numbers of |
l2 |
Optional numeric vector of level names of column 3 (factor 2)
of returned data frame. If missing it is assigned column numbers of |
Value
D |
Data frame with three columns: (y,f1,f1). |
Author(s)
Joerg Schaber
Examples
data(DWD)
M <- raw2matrix(DWD) # conversion to matrix
D1 <- matrix2raw(M) # back conversion, but with different level names
D2 <- matrix2raw(M,c(1951:1998),c(1:9)) # with original level names