Version: | 0.0-1 |
Date: | 2025-06-13 |
Title: | Indexed 'tibble' and Methods for 'dplyr' |
Depends: | R (≥ 3.5.0) |
Imports: | dplyr, vctrs, pillar, Rdpack, dfidx |
Suggests: | knitr, quarto |
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'. |
License: | GPL-2 | GPL-3 [expanded from: GPL (≥ 2)] |
URL: | https://cran.r-project.org/package=dfidx |
VignetteBuilder: | quarto |
RoxygenNote: | 7.3.1 |
Encoding: | UTF-8 |
RdMacros: | Rdpack |
NeedsCompilation: | no |
Packaged: | 2025-06-13 11:46:41 UTC; yves |
Author: | Yves Croissant [aut, cre] |
Maintainer: | Yves Croissant <yves.croissant@univ-reunion.fr> |
Repository: | CRAN |
Date/Publication: | 2025-06-16 11:30:02 UTC |
Methods for dplyr verbs
Description
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
Usage
## 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, ...)
Arguments
.data |
a dfidx object, |
... |
further arguments |
Details
These methods always return the data frame column that
contains the indexes and return a dfidx
object.
Value
an object of class "dfidx"
Author(s)
Yves Croissant
Examples
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))
Methods for dfidx
Description
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.
Usage
## 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, ...)
Arguments
x |
a |
... |
further arguments |
n |
the number of rows for the print method |
prefix_named , suffix_shape |
Value
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
Author(s)
Yves Croissant
Examples
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))
Objects exported from other packages
Description
These objects are imported from other packages. Follow the links below to see their documentation.