| h5_length | R Documentation |
Behaves like length() for R objects.
For Compound Datasets (data.frames), this is the number of columns.
For Datasets and Attributes, this is the product of all dimensions (total number of elements).
For Groups, this is the number of objects directly contained in the group.
Scalar datasets or attributes return 1.
h5_length(file, name, attr = NULL)
file |
The path to the HDF5 file. |
name |
The full path of the object (group or dataset). |
attr |
The name of an attribute to check. If provided, the length of the attribute is returned. |
An numeric scalar representing the total length (number of elements).
file <- tempfile(fileext = ".h5")
h5_write(1:100, file, "my_vec")
h5_length(file, "my_vec") # 100
h5_write(mtcars, file, "my_df")
h5_length(file, "my_df") # 11 (ncol(mtcars))
h5_write(as.matrix(mtcars), file, "my_mtx")
h5_length(file, "my_mtx") # 352 (prod(dim(mtcars)))
h5_length(file, "/") # 3
unlink(file)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.