read_matrix | R Documentation |
Reads a matrix file under strict assumptions that it is entirely numeric and there are no row or column names present in this file.
It uses readr::read_table()
to do it efficiently.
Intended for outputs such as those of admixture inference approaches.
read_matrix(file, ext = "txt", verbose = TRUE)
file |
Input file (whatever is accepted by |
ext |
The desired file extension.
Ignored if |
verbose |
If |
A numeric matrix without row or column names.
write_matrix()
, the inverse function.
# to read "data.txt", run like this: # mat <- read_matrix("data") # this also works # mat <- read_matrix("data.txt") # The following example is more awkward # because package sample data has to be specified in this weird way: # read an existing matrix *.txt file file <- system.file("extdata", 'sample-Q3.txt', package = "genio", mustWork = TRUE) mat <- read_matrix(file) mat # can specify without extension file <- sub('\\.txt$', '', file) # remove extension from this path on purpose file # verify .txt is missing mat <- read_matrix(file) # load it anyway! mat
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.