library(h5)
library(zoo)
if (file.exists('test.h5')) file.remove('test.h5')

Data Challenges

HDF5 Hierarchical Data Format

[^1]: National Center for Supercomputing Applications [^2]: National Aeronautics and Space Administration

Existing HDF5 Packages

h5: An Object Oriented Interface to HDF5

First Steps

f <- h5file('test.h5')
g1 <- f['group1']
g1['mat'] <- matrix(1:9, nrow = 3)
g1['mat2'] <- matrix(11:19, nrow = 3)
h5attr(g1, 'attr1') <- 'This is Group 1'
f['group2/mat3'] <- matrix(21:29, nrow = 3)
sapply(list.datasets(f), function(x) f[x][, 1])
h5close(f)

Extract Time Series Created from Pandas

Python:

from pandas import date_range, DataFrame
from numpy import random
t = date_range('2010-01-01', '2016-01-01', freq='D').date
randmat = random.standard_normal((len(t), 3))
df = DataFrame(randmat, index=t)
df.to_hdf('ex-pandas.h5', 'testset')

R:

f <- h5file('ex-pandas.h5', 'r')
dates <- as.Date(f['testset/axis1'][1:3], 
  origin = '0001-01-01') - 1
zoo(f['testset/block0_values'][1:3, ], order.by=dates)

Conclusion and Outlook

\center https://github.com/mannau/h5

if (file.exists('test.h5')) file.remove('test.h5')


mannau/h5 documentation built on May 21, 2019, 11:24 a.m.