Skip to contents

Convert data.frame and tibbles to matrices with named rows and columns

Usage

df2matrix(d, first_col_is_row_names = TRUE)

Arguments

d

data.frame or tibble

first_col_is_row_names

TRUE if first column has row names

Value

matrix

Examples


d <- data.frame(rname = c("x1", "x2"), x1 = c(1,2), x2 = c(3,4))
df2matrix(d)
#>    x1 x2
#> x1  1  3
#> x2  2  4