RcppCNPy-package: File access to data files written by (or for) NumPy (Numeric...

Description Usage Arguments Details Author(s) References See Also Examples

Description

This package provides access to the cnpy library by Carl Rogers which provides read and write facilities for files created with (or for) the NumPy extension for Python.

Support is currently limited to reading and writing of either vectors or matrices of numeric types. Integer support can be added if the package, as well Rcpp are recompiled using the -std=c++11 flag.

Files with gzip compression can be transparently read and written as well.

Usage

1
2
3
  npyLoad(filename, type="numeric", dotranspose=TRUE)
  npySave(filename, object, mode="w")
  npyHasIntegerSupport()

Arguments

filename

string with (path and) filename for a npy object file. If the string ends with .gz, compressed files can be read or written.

type

string with type 'numeric' (default) or 'integer'. Integer support is available only if Rcpp and RcppCNPy have been compiled with the -std=c++0x option as the required int64_t types are not available otherwise.

object

an R object, currently limited to a vector or matrix of either integer or numeric type

dotranspose

a boolean variable indicating whether a two-dimensional object should be transposed after reading, default is yes

mode

a one-character string indicating whether files are appended to ("a") or written ("w", the default). In case of writing gzip-ed file, this option is not supported as such files can only be (over-)written, and bot appended.

Details

The package uses Rcpp modules to provide R bindings npyLoad() and npySave() which wrap the npy_load() and npy_save() functions. Currently, only one- and two-dimensional vectors and matrices are suppported; higher-dimensional arrays could be added.

Author(s)

Dirk Eddelbuettel provided the binding to R (using the Rcpp package).

Carl Rogers wrote the underlying cnpy library, which is released under the MIT license.

Maintainer: Dirk Eddelbuettel <edd@debian.org>

References

Rcpp, in particular the Rcpp modules documentation.

The cnpy repository: https://github.com/rogersce/cnpy

See Also

Rcpp

Examples

1
  ## TODO, but see demo()

RcppCNPy documentation built on May 2, 2019, 4:52 p.m.