rhdf5: Package overview

Description Package content Authors Examples

Description

rhdf5 is an interface to the HDF5 library. The R-package contains the complete HDF5 library, thus no further installation of external packages is necessary.

There are a number of high level R functions that provide a convinient way of accessing HDF5 file as well as R interfaces to a number of functions in the C-library.

Package content

HDF5 file, group, dataset creation

HDF5 file content listing

Reading and writing data

HDF5 constants

HDF5 version number

Low level interface to HDF5 C-library (for expert users only!):

Authors

R-interface by

Bernd Fischer, bernd.fischer@embl.de EMBL - European Molecular Biology Laboratory Heidelberg Germany

The package contains the HDF5 library (https://portal.hdfgroup.org/display/HDF5).

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
h5createFile("ex_hdf5file.h5")

# create groups
h5createGroup("ex_hdf5file.h5","foo")
h5createGroup("ex_hdf5file.h5","foo/foobaa")

# write a matrix
B = array(seq(0.1,2.0,by=0.1),dim=c(5,2,2))
attr(B, "scale") <- "liter"
h5write(B, "ex_hdf5file.h5","foo/B")

# read a matrix
E = h5read("ex_hdf5file.h5","foo/B")

# list content of hdf5 file
h5ls("ex_hdf5file.h5")

# write and read submatrix
h5createDataset("ex_hdf5file.h5", "foo/S", c(5,8), storage.mode = "integer", chunk=c(5,1), level=7)
h5write(matrix(1:5,nr=5,nc=1), file="ex_hdf5file.h5", name="foo/S", index=list(NULL,1))
h5read("ex_hdf5file.h5", "foo/S")
h5read("ex_hdf5file.h5", "foo/S", index=list(2:3,2:3))

Example output

[1] TRUE
[1] TRUE
[1] TRUE
  group   name       otype dclass       dim
0     /    foo   H5I_GROUP                 
1  /foo      B H5I_DATASET  FLOAT 5 x 2 x 2
2  /foo foobaa   H5I_GROUP                 
[1] TRUE
     [,1] [,2] [,3] [,4] [,5] [,6] [,7] [,8]
[1,]    1    0    0    0    0    0    0    0
[2,]    2    0    0    0    0    0    0    0
[3,]    3    0    0    0    0    0    0    0
[4,]    4    0    0    0    0    0    0    0
[5,]    5    0    0    0    0    0    0    0
     [,1] [,2]
[1,]    0    0
[2,]    0    0

rhdf5 documentation built on Nov. 8, 2020, 6:56 p.m.