Title: | Dimensional Data Frames |
---|---|
Description: | Provides a 'dibble' that implements data cubes (derived from 'dimensional tibble'), and allows broadcasting by dimensional names. |
Authors: | Mizuki Uchida [aut, cre] |
Maintainer: | Mizuki Uchida <[email protected]> |
License: | MIT + file LICENSE |
Version: | 0.3.0.9000 |
Built: | 2024-11-22 04:52:32 UTC |
Source: | https://github.com/uchidamizuki/dibble |
Applying a function to margins of a dibble or array, including a matrix.
apply(X, MARGIN, FUN, ...) ## Default S3 method: apply(X, MARGIN, FUN, ..., simplify = TRUE) ## S3 method for class 'tbl_ddf' apply(X, MARGIN, FUN, ...) ## S3 method for class 'ddf_col' apply(X, MARGIN, FUN, ...)
apply(X, MARGIN, FUN, ...) ## Default S3 method: apply(X, MARGIN, FUN, ..., simplify = TRUE) ## S3 method for class 'tbl_ddf' apply(X, MARGIN, FUN, ...) ## S3 method for class 'ddf_col' apply(X, MARGIN, FUN, ...)
X |
A dibble or array, including a matrix. |
MARGIN |
An integer or character vector giving the subscripts which the function will be applied over. |
FUN |
A function to be applied. |
... |
Optional arguments to FUN. |
simplify |
A logical indicating whether results should be simplified if possible. |
apply()
overrides base::apply()
to make it generic. The default method
calls the base version.
A dibble if X is a dibble. See base::apply()
for the return value
of the default method.
x <- array(1:24, 2:4, list(axis1 = letters[1:2], axis2 = letters[1:3], axis3 = letters[1:4])) apply(x, 2:3, sum) apply(as_dibble(x), 2:3, sum) apply(x, c("axis2", "axis3"), sum) apply(as_dibble(x), c("axis2", "axis3"), sum)
x <- array(1:24, 2:4, list(axis1 = letters[1:2], axis2 = letters[1:3], axis3 = letters[1:4])) apply(x, 2:3, sum) apply(as_dibble(x), 2:3, sum) apply(x, c("axis2", "axis3"), sum) apply(as_dibble(x), c("axis2", "axis3"), sum)
as_dibble()
turns an object into a dimensional data frame called a dibble.
as_dibble(x, ...) ## Default S3 method: as_dibble(x, ...) ## S3 method for class 'rowwise_df' as_dibble(x, ...) ## S3 method for class 'grouped_df' as_dibble(x, ...) ## S3 method for class 'ddf_col' as_dibble(x, ...) ## S3 method for class 'tbl_ddf' as_dibble(x, ...)
as_dibble(x, ...) ## Default S3 method: as_dibble(x, ...) ## S3 method for class 'rowwise_df' as_dibble(x, ...) ## S3 method for class 'grouped_df' as_dibble(x, ...) ## S3 method for class 'ddf_col' as_dibble(x, ...) ## S3 method for class 'tbl_ddf' as_dibble(x, ...)
x |
An object. |
... |
Unused, for extensibility. |
A dibble.
Create basic matrices and arrays.
eye(x, ...) ## Default S3 method: eye(x, y = x, ...) ## S3 method for class 'matrix' eye(x, ...) ## S3 method for class 'ddf_col' eye(x, ...) ## S3 method for class 'tbl_ddf' eye(x, ...) ones(x, ...) ## Default S3 method: ones(x, y = x, ...) ## S3 method for class 'array' ones(x, ...) ## S3 method for class 'ddf_col' ones(x, ...) ## S3 method for class 'tbl_ddf' ones(x, ...) zeros(x, ...) ## Default S3 method: zeros(x, y = x, ...) ## S3 method for class 'array' zeros(x, ...) ## S3 method for class 'ddf_col' zeros(x, ...) ## S3 method for class 'tbl_ddf' zeros(x, ...)
eye(x, ...) ## Default S3 method: eye(x, y = x, ...) ## S3 method for class 'matrix' eye(x, ...) ## S3 method for class 'ddf_col' eye(x, ...) ## S3 method for class 'tbl_ddf' eye(x, ...) ones(x, ...) ## Default S3 method: ones(x, y = x, ...) ## S3 method for class 'array' ones(x, ...) ## S3 method for class 'ddf_col' ones(x, ...) ## S3 method for class 'tbl_ddf' ones(x, ...) zeros(x, ...) ## Default S3 method: zeros(x, y = x, ...) ## S3 method for class 'array' zeros(x, ...) ## S3 method for class 'ddf_col' zeros(x, ...) ## S3 method for class 'tbl_ddf' zeros(x, ...)
x |
An object. |
... |
Other arguments passed on to methods. |
y |
A scalar integer. |
These functions override base functions to make them generic. The default methods call the base versions.
A dibble if x is a dibble. Otherwise, returns a matrix or an array.
Broadcasts the dimension of the object to a new dimension.
broadcast(x, dim_names = NULL, ...) ## Default S3 method: broadcast(x, dim_names = NULL, ...) ## S3 method for class 'ddf_col' broadcast(x, dim_names, ...) ## S3 method for class 'tbl_ddf' broadcast(x, dim_names, ...)
broadcast(x, dim_names = NULL, ...) ## Default S3 method: broadcast(x, dim_names = NULL, ...) ## S3 method for class 'ddf_col' broadcast(x, dim_names, ...) ## S3 method for class 'tbl_ddf' broadcast(x, dim_names, ...)
x |
A dibble, vector, or array. |
dim_names |
A character vector or list of dimension names. |
... |
Unused, for extensibility. |
Operations between dibbles are automatically broadcasted, but for safety
reasons, warnings are issued.
broadcast()
can suppress the warnings if dim_names
matches the dimension
of x
.
A dibble.
x <- broadcast(1:2, list(axis1 = letters[1:2])) y <- broadcast(1:3, list(axis2 = letters[1:3])) broadcast(x * y, c("axis1", "axis2"))
x <- broadcast(1:2, list(axis1 = letters[1:2])) y <- broadcast(1:3, list(axis2 = letters[1:3])) broadcast(x * y, c("axis1", "axis2"))
Extract or replace the diagonal of a matrix, or construct a diagonal matrix.
diag(x, ...) ## Default S3 method: diag(x = 1, nrow, ncol, names, ...) ## S3 method for class 'tbl_ddf' diag(x, axes, ...) ## S3 method for class 'ddf_col' diag(x, axes, ...) diag(x, ...) <- value ## Default S3 replacement method: diag(x, ...) <- value ## S3 replacement method for class 'tbl_ddf' diag(x, ...) <- value ## S3 replacement method for class 'ddf_col' diag(x, ...) <- value
diag(x, ...) ## Default S3 method: diag(x = 1, nrow, ncol, names, ...) ## S3 method for class 'tbl_ddf' diag(x, axes, ...) ## S3 method for class 'ddf_col' diag(x, axes, ...) diag(x, ...) <- value ## Default S3 replacement method: diag(x, ...) <- value ## S3 replacement method for class 'tbl_ddf' diag(x, ...) <- value ## S3 replacement method for class 'ddf_col' diag(x, ...) <- value
x |
A dibble, matrix, vector or 1D array, or missing. |
... |
Unused, for extensibility. |
nrow , ncol
|
Optional dimensions for the result when x is not a matrix. |
names |
(When x is a matrix) logical indicating if the resulting vector, the diagonal of x, should inherit names from dimnames(x) if available. |
axes |
A character vector of axes. |
value |
Replacement values. |
These functions override base functions to make them generic. The default methods call the base versions.
A dibble if x is a dibble. See base::diag()
for the return values
of the default methods.
dibble()
constructs a dimensional data frame called a dibble.
dibble(..., .dim_names = NULL)
dibble(..., .dim_names = NULL)
... |
A set of name-measure pairs. |
.dim_names |
A list of dimension names. |
Manipulation functions:
mutate()
rename()
select() & relocate()
slice()
A dibble.
dibble_by()
constructs a dibble by one or more variables.
dibble_by(x, ..., .names_sep = NULL)
dibble_by(x, ..., .names_sep = NULL)
x |
A data frame or a dibble. |
... |
Variables. |
.names_sep |
Passed to |
A dibble.
Returns the parallel maxima and minima of the input values.
pmax(..., na.rm = FALSE) ## Default S3 method: pmax(..., na.rm = FALSE) ## S3 method for class 'ddf_col' pmax(..., na.rm = FALSE) ## S3 method for class 'tbl_ddf' pmax(..., na.rm = FALSE) pmin(..., na.rm = FALSE) ## Default S3 method: pmin(..., na.rm = FALSE) ## S3 method for class 'ddf_col' pmin(..., na.rm = FALSE) ## S3 method for class 'tbl_ddf' pmin(..., na.rm = FALSE)
pmax(..., na.rm = FALSE) ## Default S3 method: pmax(..., na.rm = FALSE) ## S3 method for class 'ddf_col' pmax(..., na.rm = FALSE) ## S3 method for class 'tbl_ddf' pmax(..., na.rm = FALSE) pmin(..., na.rm = FALSE) ## Default S3 method: pmin(..., na.rm = FALSE) ## S3 method for class 'ddf_col' pmin(..., na.rm = FALSE) ## S3 method for class 'tbl_ddf' pmin(..., na.rm = FALSE)
... |
Dibbles, numeric or character arguments. |
na.rm |
a logical indicating whether missing values should be removed. |
These functions override base functions to make them generic. The default methods call the base versions.
A dibble if ...
are dibbles. See base::pmax()
and base::pmin()
for the return value of the default method.
Selects elements from either yes
or no
depending on whether test
is
TRUE
or FALSE
.
ifelse(test, yes, no, ...) ## Default S3 method: ifelse(test, yes, no, ...) ## S3 method for class 'tbl_ddf' ifelse(test, yes, no, ...) ## S3 method for class 'ddf_col' ifelse(test, yes, no, ...)
ifelse(test, yes, no, ...) ## Default S3 method: ifelse(test, yes, no, ...) ## S3 method for class 'tbl_ddf' ifelse(test, yes, no, ...) ## S3 method for class 'ddf_col' ifelse(test, yes, no, ...)
test |
An object which can be coerced to logical mode. |
yes |
Return values for true elements of test. |
no |
Return values for false elements of test. |
... |
Unused, for extensibility. |
ifelse()
overrides base::ifelse()
to make it generic. The default method
calls the base version.
A dibble if test is a dibble. See base::ifelse()
for the return
value of the default method.
Test if the object is a dibble
is_dibble(x)
is_dibble(x)
x |
An object. |
A logical.
nrow()
and ncol()
return the number of rows or columns present in x.
nrow(x, ...) ## Default S3 method: nrow(x, ...) ## S3 method for class 'ddf_col' nrow(x, ...) ## S3 method for class 'tbl_ddf' nrow(x, ...) ncol(x, ...) ## Default S3 method: ncol(x, ...) ## S3 method for class 'ddf_col' ncol(x, ...) ## S3 method for class 'tbl_ddf' ncol(x, ...)
nrow(x, ...) ## Default S3 method: nrow(x, ...) ## S3 method for class 'ddf_col' nrow(x, ...) ## S3 method for class 'tbl_ddf' nrow(x, ...) ncol(x, ...) ## Default S3 method: ncol(x, ...) ## S3 method for class 'ddf_col' ncol(x, ...) ## S3 method for class 'tbl_ddf' ncol(x, ...)
x |
An object. |
... |
Other arguments passed on to methods. |
These functions override base functions to make them generic. The default methods call the base versions.
An integer or NULL
.
Retrieve or set the row or column names of a matrix-like object.
rownames(x, ...) ## Default S3 method: rownames(x, ...) ## S3 method for class 'ddf_col' rownames(x, ...) ## S3 method for class 'tbl_ddf' rownames(x, ...) colnames(x, ...) ## Default S3 method: colnames(x, ...) ## S3 method for class 'ddf_col' colnames(x, ...) ## S3 method for class 'tbl_ddf' colnames(x, ...)
rownames(x, ...) ## Default S3 method: rownames(x, ...) ## S3 method for class 'ddf_col' rownames(x, ...) ## S3 method for class 'tbl_ddf' rownames(x, ...) colnames(x, ...) ## Default S3 method: colnames(x, ...) ## S3 method for class 'ddf_col' colnames(x, ...) ## S3 method for class 'tbl_ddf' colnames(x, ...)
x |
A matrix-like object. |
... |
Other arguments passed on to methods. |
These functions override base functions to make them generic. The default methods call the base versions.
A list of row/column names.