JMatToCsv: JMatToCsv

View source: R/RcppExports.R

JMatToCsvR Documentation

JMatToCsv

Description

Writes a binary matrix in the jmatrix package format as a .csv file. This is mainly for checking/inspection and to load the data from R as read.csv, if the memory of having all data as doubles allows doing such thing.

Usage

JMatToCsv(ifile, csvfile, csep = ",", withquotes = FALSE)

Arguments

ifile

String with the file name that contains the binary data.

csvfile

String with the file name that will contain the data as csv.

csep

Character used as separator. Default: , (comma)

withquotes

boolean to mark if row and column names in the .csv file must be written surrounded by doble quotes. Default: FALSE

Details

The numbers are written to text with as many decimal places as allowed by its data type (internally obtained with std::numeric_limits<type>::max_digits10)
NOTE ON READING FROM R: to read the .csv files exported by this function you MUST use the R function read.csv (not read.table) AND set its argument row.names to 1, since we always write a first column with the row names, even if the binary matrix does not store them; in this case they are simply "1","2",...

Value

No return value, called for side effects (creates a file)

Examples

Rf <- matrix(runif(48),nrow=6)
rownames(Rf) <- c("A","B","C","D","E","F")
colnames(Rf) <- c("a","b","c","d","e","f","g","h")
tmpfile1=paste0(tempdir(),"/Rfullfloat.bin")
tmpcsvfile1=paste0(tempdir(),"/Rfullfloat.csv")
JWriteBin(Rf,tmpfile1,dtype="float",dmtype="full",comment="Full matrix of floats")
JMatToCsv(tmpfile1,tmpcsvfile1)

jmatrix documentation built on Oct. 9, 2023, 1:06 a.m.