Learn R Programming

dfidx (version 0.1-0)

idx: Index for dfidx

Description

The index of a dfidx is a data.frame containing the different series which define the two indexes (with possibly a nesting structure). It is stored as a "sticky" data.frame column of the data.frame and is also inherited by series (of class 'xseries') which are extracted from a dfidx.

Usage

idx(x, n = NULL, m = NULL)

# S3 method for dfidx idx(x, n = NULL, m = NULL)

# S3 method for idx idx(x, n = NULL, m = NULL)

# S3 method for xseries idx(x, n = NULL, m = NULL)

# S3 method for idx format(x, size = 4, ...)

Value

a data.frame containing the indexes or a series if a specific index is selected

Arguments

x

a dfidx or a xseries

n, m

n is the index to be extracted (1 or 2), m equal to one to get the index, greater than one to get a nesting variable.

size

the number of characters of the indexes for the format method

...

further arguments (for now unused)

Author

Yves Croissant

Details

idx is defined as a generic with a dfidx and a xseries method.

Examples

Run this code
mn <- dfidx(munnell, idx = c(region = "state", president = "year"))
idx(mn)
gsp <- mn$gsp
idx(gsp)
# get the first index
idx(mn, 1)
# get the nesting variable of the first index
idx(mn, 1, 2)

Run the code above in your browser using DataLab