Skip to content

Commit

Permalink
Add examples
Browse files Browse the repository at this point in the history
  • Loading branch information
mannau committed Oct 13, 2017
1 parent 0658126 commit 054af4a
Show file tree
Hide file tree
Showing 14 changed files with 143 additions and 9 deletions.
17 changes: 16 additions & 1 deletion R/R6Classes_H5A.R
Expand Up @@ -31,8 +31,23 @@
##' @docType class
##' @importFrom R6 R6Class
##' @return Object of class \code{\link{H5A}}.
##' @export
##' @author Holger Hoefling
##' @examples
##' fname <- tempfile(fileext = ".h5")
##' file <- H5File$new(fname, mode = "a")
##' h5attr(file, "attr_numeric") <- rnorm(10)
##' a <- file$attr_open("attr_numeric")
##' a$get_info()
##' a$attr_name()
##' a$get_space()
##' a$get_type()
##' a$get_storage_size()
##' a$read()
##' a$write(10:1)
##' a$print()
##' a$close()
##' file$close_all()
##' @export
H5A <- R6Class("H5A",
inherit=H5RefClass,
public=list(
Expand Down
2 changes: 1 addition & 1 deletion R/R6Classes_H5D.R
Expand Up @@ -61,7 +61,6 @@ setOldClass("H5D")
##' @docType class
##' @importFrom R6 R6Class
##' @return Object of class \code{\link{H5D}}.
##' @export
##' @author Holger Hoefling
##' @examples
##' # First create a file to create datasets in it
Expand Down Expand Up @@ -96,6 +95,7 @@ setOldClass("H5D")
##'
##' file$close_all()
##' file.remove(fname)
##' @export
H5D <- R6Class("H5D",
inherit=H5RefClass,
public=list(
Expand Down
7 changes: 7 additions & 0 deletions R/R6Classes_H5Group.R
Expand Up @@ -33,6 +33,13 @@
##' @return Object of class \code{\link{H5Group}}.
##' @export
##' @author Holger Hoefling
##' @examples
##' fname <- tempfile(fileext = ".h5")
##' file <- H5File$new(fname, mode = "a")
##' group <- file$create_group("testgroup")
##' group$print()
##' group$close()
##' file$close_all()
H5Group <- R6Class("H5Group",
inherit=H5RefClass,
public=list(
Expand Down
12 changes: 11 additions & 1 deletion R/R6Classes_H5P.R
Expand Up @@ -106,8 +106,18 @@ H5P_factory <- function(id) {
#' @docType class
#' @importFrom R6 R6Class
#' @return Object of class \code{\link{H5P}}.
#' @export
#' @author Holger Hoefling
#' @examples
#' fname <- tempfile(fileext = ".h5")
#' file <- H5File$new(fname, mode = "a")
#' file[["testdataset"]] <- 1:10
#' p <- file[["testdataset"]]$get_create_plist()
#' p$get_class()
#' p$get_class_name()
#' p$copy()
#' p$equal(p)
#' file$close_all()
#' @export
H5P <- R6Class("H5P",
inherit=H5RefClass,
public=list(
Expand Down
9 changes: 8 additions & 1 deletion R/R6Classes_H5R.R
Expand Up @@ -37,8 +37,15 @@ ref_obj_size <- new.env()
#' @docType class
#' @importFrom R6 R6Class
#' @return Object of class \code{\link[=H5R]{H5R}}.
#' @export
#' @author Holger Hoefling
#' @examples
#' fname <- tempfile(fileext = ".h5")
#' file <- H5File$new(fname, mode = "a")
#' file[["testset"]] <- matrix(rnorm(9), nrow = 3)
#' dset <- file[["testset"]]
#' r <- file$create_reference("testset")
#' file$close_all()
#' @export
H5R <- R6Class("H5R",
inherit=H5RefClass,
public=list(
Expand Down
3 changes: 1 addition & 2 deletions R/R6Classes_H5S.R
Expand Up @@ -36,7 +36,6 @@
##' @docType class
##' @importFrom R6 R6Class
##' @return Object of class \code{\link{H5S}}.
##' @export
##' @author Holger Hoefling
##'
##' @examples
Expand All @@ -58,7 +57,7 @@
##' h5s_variable[2:7, 1:2]
##' h5s_variable$get_select_type()
##' h5s_variable$get_select_hyper_blocklist()
##'
##' @export
H5S <- R6Class("H5S",
inherit=H5RefClass,
public=list(
Expand Down
2 changes: 1 addition & 1 deletion R/R6Classes_H5T.R
Expand Up @@ -163,7 +163,6 @@ text_to_dtype <- function(text, lang_type=h5const$H5LT_DDL) {
#' @docType class
#' @importFrom R6 R6Class
#' @return Object of class \code{\link{H5T}}.
#' @export
#' @author Holger Hoefling
#'
#' @examples
Expand All @@ -184,6 +183,7 @@ text_to_dtype <- function(text, lang_type=h5const$H5LT_DDL) {
#'
#' file$close_all()
#' file.remove(fname)
#' @export
H5T <- R6Class("H5T",
inherit=H5RefClass,
public=list(
Expand Down
28 changes: 27 additions & 1 deletion R/hdf5r.R
Expand Up @@ -36,7 +36,33 @@ NULL
##'
##' @name hdf5r-package
##' @docType package
##'
##' @examples
##' test_file <- tempfile(fileext=".h5")
##' file.h5 <- H5File$new(test_file, mode="w")
##'
##' data(cars)
##' file.h5$create_group("test")
##' file.h5[["test/cars"]] <- cars
##' cars_ds <- file.h5[["test/cars"]]
##' h5attr(cars_ds, "rownames") <- rownames(cars)
##'
##' # Close the file at the end
##' # the 'close' method closes only the file-id, but leaves object inside the file open
##' # This may prevent re-opening of the file. 'close_all' closes the file and all objects in it
##' file.h5$close_all()
##' # now re-open it
##' file.h5 <- H5File$new(test_file, mode="r+")
##'
##' # lets look at the content
##' file.h5$ls(recursive=TRUE)
##'
##' cars_ds <- file.h5[["test/cars"]]
##' # note that for now tables in HDF5 are 1-dimensional, not 2-dimensional
##' mycars <- cars_ds[]
##' h5attr_names(cars_ds)
##' h5attr(cars_ds, "rownames")
##'
##' file.h5$close_all()
NULL


Expand Down
16 changes: 16 additions & 0 deletions man/H5A-class.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions man/H5Group-class.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

11 changes: 11 additions & 0 deletions man/H5P-class.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions man/H5R-class.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion man/H5S-class.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

28 changes: 28 additions & 0 deletions man/hdf5r-package.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 054af4a

Please sign in to comment.