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 dfidx
[(x, i, j, drop)# S3 method for dfidx
as.data.frame(x, row.names = NULL, optional = FALSE, ...)
# S3 method for dfidx
print(x, ..., n = 10L)
# S3 method for dfidx
head(x, n = 10L, ...)
# S3 method for dfidx
[[(x, y)
# S3 method for dfidx
$(x, y)
# S3 method for dfidx
$(object, y) <- value
# S3 method for dfidx
[[(object, y) <- value
# S3 method for xseries
print(x, ..., n = 10L)
# S3 method for idx
print(x, ..., n = 10L)
# S3 method for dfidx
mean(x, ...)
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
a dfidx
object
the row index
the column index
if TRUE
a vector is returned if the result is a one
column data.frame
arguments of the generic as.data.frame
method, not used
further arguments
the number of rows for the print method
the name or the position of the series one wishes to extract
the value for the replacement method
Yves Croissant
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))
Run the code above in your browser using DataLab