Description Usage Arguments Value Author(s) See Also Examples
View source: R/matrix2longdf.R
Input data.frame must contain at least three columns: one contains row names
(specified by row.col
), one contains column names
(column.col
), and one contains values in matrix cells
(value.col
). The output is a 2D matrix.
1 2 3 4 5 6 7 | longdf2matrix(
df,
row.col = 1L,
column.col = 2L,
value.col = 3L,
missingValue = NULL
)
|
df |
Long-format data frame |
row.col |
Character or integer, which column of the input data.frame contains row names? |
column.col |
Character or integer, which column contains column names? |
value.col |
Character or integer, which column contains matrix values? |
missingValue |
Values assigned in case of missing data |
A 2D matrix equivalent to the long-format data frame
Jitao David Zhang <jitao_david.zhang@roche.com>
1 2 3 4 5 6 7 8 | test.df <- data.frame(H=c("HSV", "BVB", "HSV", "BVB"),
A=c("FCB", "S04", "S04", "FCB"),
score=c(3, 1, 1, 0))
longdf2matrix(test.df, row.col=1L, column.col=2L, value.col=3L)
data(Indometh)
longdf2matrix(Indometh, row.col="time", column.col="Subject",value.col="conc")
longdf2matrix(Indometh, row.col="Subject", column.col="time", value.col="conc")
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.