h5save: h5save

Usage Arguments Examples

View source: R/do.r

Usage

1

Arguments

X
file

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
##---- Should be DIRECTLY executable !! ----
##-- ==>  Define data, use random,
##--	or do  help(data=index)  for the standard data sets.

## The function is currently defined as
function (X, file) 
{
    node2group = function(file, path, node) {
        for (i in seq_along(node)) {
            nval = node[[i]]
            npath = .jp(path, names(node)[i])
            h5createGroup(file, npath)
            if (is.data.frame(nval)) 
                nval = as.matrix(nval)
            if (is.list(nval)) {
                for (j in seq_along(nval)) node2group(file, npath, 
                  nval[j])
            }
            else {
                nval = as.array(nval)
                h5write(nval, file, .jp(npath, "value"))
                for (j in 1:length(dim(nval))) if (!is.null(dimnames(nval)[[j]])) 
                  h5write(dimnames(nval)[[j]], file, .jp(npath, 
                    paste0("names_", j)))
            }
        }
    }
    h5createFile(file)
    node2group(file, "", X)
  }

mschubert/r-h5store documentation built on May 23, 2019, 7:51 a.m.