Convert matrix to data.table
matrix_to_dt.Rd
Convert matrix to data.table
Examples
x <- matrix(runif(9), 3, 3)
rownames(x) <- letters[1:3]
colnames(x) <- letters[4:6]
matrix_to_dt(x)
#> row col val
#> <char> <char> <num>
#> 1: a d 0.64964580
#> 2: b d 0.45305071
#> 3: c d 0.16083224
#> 4: a e 0.41465647
#> 5: b e 0.52798959
#> 6: c e 0.15063055
#> 7: a f 0.30036994
#> 8: b f 0.67204673
#> 9: c f 0.08181922
matrix_to_dt(x, 'sample', 'gene', 'expression')
#> sample gene expression
#> <char> <char> <num>
#> 1: a d 0.64964580
#> 2: b d 0.45305071
#> 3: c d 0.16083224
#> 4: a e 0.41465647
#> 5: b e 0.52798959
#> 6: c e 0.15063055
#> 7: a f 0.30036994
#> 8: b f 0.67204673
#> 9: c f 0.08181922