longdf2matrix: Convert a long-format data frame into matrix

Description Usage Arguments Value Author(s) See Also Examples

View source: R/matrix2longdf.R

Description

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.

Usage

1
2
3
4
5
6
7
longdf2matrix(
  df,
  row.col = 1L,
  column.col = 2L,
  value.col = 3L,
  missingValue = NULL
)

Arguments

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

Value

A 2D matrix equivalent to the long-format data frame

Author(s)

Jitao David Zhang <jitao_david.zhang@roche.com>

See Also

matrix2longdf

Examples

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")

ribiosUtils documentation built on March 13, 2020, 2:54 a.m.