| Title: | Indexed 'tibble' and Methods for 'dplyr' |
|---|---|
| Description: | Provides extended data frames, with a special data frame column which contains two indexes, with potentially a nesting structure, and support for tibbles and methods for 'dplyr'. |
| Authors: | Yves Croissant [aut, cre] |
| Maintainer: | Yves Croissant <[email protected]> |
| License: | GPL (>=2) |
| Version: | 0.0-3 |
| Built: | 2026-05-07 08:49:25 UTC |
| Source: | https://github.com/ycroissant/tidydfidx |
methods of dplyr verbs for dfidx objects. Default functions
don't work because most of these functions returns either a
tibble or a data.frame but not a dfidx
## S3 method for class 'dfidx' arrange(.data, ...) ## S3 method for class 'dfidx' filter(.data, ...) ## S3 method for class 'dfidx' slice(.data, ...) ## S3 method for class 'dfidx' mutate(.data, ...) ## S3 method for class 'dfidx' transmute(.data, ...) ## S3 method for class 'dfidx' select(.data, ...)## S3 method for class 'dfidx' arrange(.data, ...) ## S3 method for class 'dfidx' filter(.data, ...) ## S3 method for class 'dfidx' slice(.data, ...) ## S3 method for class 'dfidx' mutate(.data, ...) ## S3 method for class 'dfidx' transmute(.data, ...) ## S3 method for class 'dfidx' select(.data, ...)
.data |
a dfidx object, |
... |
further arguments |
These methods always return the data frame column that
contains the indexes and return a dfidx object.
an object of class "dfidx"
Yves Croissant
data("munnell", package = "dfidx") munnell <- as_tibble(munnell) mn <- dfidx(munnell) select(mn, - gsp, - water) mutate(mn, lgsp = log(gsp), lgsp2 = lgsp ^ 2) transmute(mn, lgsp = log(gsp), lgsp2 = lgsp ^ 2) arrange(mn, desc(unemp), labor) filter(mn, unemp > 10) pull(mn, gsp) slice(mn, c(1:2, 5:7))data("munnell", package = "dfidx") munnell <- as_tibble(munnell) mn <- dfidx(munnell) select(mn, - gsp, - water) mutate(mn, lgsp = log(gsp), lgsp2 = lgsp ^ 2) transmute(mn, lgsp = log(gsp), lgsp2 = lgsp ^ 2) arrange(mn, desc(unemp), labor) filter(mn, unemp > 10) pull(mn, gsp) slice(mn, c(1:2, 5:7))
A dfidx is a data.frame with a "sticky" data.frame column
which contains the indexes. Specific methods of functions that
extract lines and/or columns of a data.frame are provided.
## S3 method for class 'tbl_dfidx' print(x, ..., n = NULL) ## S3 method for class 'vecidx' vec_ptype_abbr(x, ..., prefix_named, suffix_shape) ## S3 method for class 'vecidx' format(x, ...) ## S3 method for class 'vecidx' pillar_shaft(x, ...) ## S3 method for class 'tbl_dfidx2' tbl_sum(x, ...)## S3 method for class 'tbl_dfidx' print(x, ..., n = NULL) ## S3 method for class 'vecidx' vec_ptype_abbr(x, ..., prefix_named, suffix_shape) ## S3 method for class 'vecidx' format(x, ...) ## S3 method for class 'vecidx' pillar_shaft(x, ...) ## S3 method for class 'tbl_dfidx2' tbl_sum(x, ...)
x |
a |
... |
further arguments |
n |
the number of rows for the print method |
prefix_named, suffix_shape
|
as.data.frame and mean return a data.frame, [[ and
$ a vector, [ either a dfidx or a vector, $<-
and [[<- modify the values of an existing column or create a
new column of a dfidx object, print is called for its side
effect
Yves Croissant
data("munnell", package = "dfidx") mn <- dfidx(munnell) # extract a series (returns as a xseries object) mn$gsp # or mn[["gsp"]] # extract a subset of series (returns as a dfidx object) mn[c("gsp", "unemp")] # extract a subset of rows and columns mn[mn$unemp > 10, c("utilities", "water")] # dfidx, idx and xseries have print methods as (like tibbles), a n # argument print(mn, n = 3) print(idx(mn), n = 3) print(mn$gsp, n = 3) # a dfidx object can be coerced to a data.frame head(as.data.frame(mn))data("munnell", package = "dfidx") mn <- dfidx(munnell) # extract a series (returns as a xseries object) mn$gsp # or mn[["gsp"]] # extract a subset of series (returns as a dfidx object) mn[c("gsp", "unemp")] # extract a subset of rows and columns mn[mn$unemp > 10, c("utilities", "water")] # dfidx, idx and xseries have print methods as (like tibbles), a n # argument print(mn, n = 3) print(idx(mn), n = 3) print(mn$gsp, n = 3) # a dfidx object can be coerced to a data.frame head(as.data.frame(mn))