methods.dfidx {dfidx} | R Documentation |
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 'dfidx'
x[i, j, drop = TRUE]
## S3 method for class 'dfidx'
as.data.frame(x, row.names = NULL, optional = FALSE, ...)
## S3 method for class 'dfidx'
print(x, ..., n = 10L)
## S3 method for class 'dfidx'
head(x, n = 10L, ...)
## S3 method for class 'dfidx'
x[[y]]
## S3 method for class 'dfidx'
x$y
## S3 replacement method for class 'dfidx'
object$y <- value
## S3 replacement method for class 'dfidx'
object[[y]] <- value
## S3 method for class 'xseries'
print(x, ..., n = 10L)
## S3 method for class 'idx'
print(x, ..., n = 10L)
## S3 method for class 'dfidx'
mean(x, ...)
Arguments
x , object |
a |
i |
the row index |
j |
the column index |
drop |
if |
row.names , optional |
arguments of the generic |
... |
further arguments |
n |
the number of rows for the print method |
y |
the name or the position of the series one wishes to extract |
value |
the value for the replacement method |
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
if (requireNamespace("AER")){
data("TravelMode", package = "AER")
TM <- dfidx(TravelMode)
# extract a series (returns as a xseries object)
TM$wait
# or
TM[["wait"]]
# extract a subset of series (returns as a dfidx object)
TM[c("wait", "income")]
# extract a subset of rows and columns
TM[TM$income > 30, c("wait", "income")]
# dfidx, idx and xseries have print methods as (like tibbles), a n
# argument
print(TM, n = 3)
print(idx(TM), n = 3)
print(TM$income, n = 3)
# a dfidx object can be coerced to a data.frame
head(as.data.frame(TM))
}
[Package dfidx version 0.0-5 Index]