Skip to content

Commit

Permalink
R to Divvy exporter. Thanks to Tom Wisdom for contributing the base c…
Browse files Browse the repository at this point in the history
…ode.
  • Loading branch information
Joshua M. Lewis committed Feb 9, 2012
1 parent e2eb5a6 commit 00bee92
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions Exporters/rtodivvy.r
@@ -0,0 +1,20 @@
#### R data.frame to Divvy binary file export written by Tom Wisdom
#### & Josh Lewis 2012
rtodivvy <- function(inputData, name) {
# Data must be dense and real-valued. Check for this in the future.
# Dimensions are in columns & samples are in rows unlike the Matlab
# exporter but as per R convention.
dimensions <- length(inputData[1,])
samples <- length(inputData[,1])
# Concatenate rows (after converting data.frame to matrix and values to double)
inputData_vec <- as.double(t(as.matrix(inputData)))

filename <- paste(name, ".bin", sep="")
fid <- file(description = filename, open = "wb")

writeBin(samples, fid, size=4)
writeBin(dimensions, fid, size=4)
writeBin(inputData_vec, fid, size=4)

close(fid)
}

0 comments on commit 00bee92

Please sign in to comment.