idx_name: Get the name and the position of the index column

View source: R/miscellaneous.R

idx_nameR Documentation

Get the name and the position of the index column

Description

This function extract the names of the indexes (along with the position of the idx column) or the name of a specific index

Usage

idx_name(x, n = 1, m = NULL)

## S3 method for class 'dfidx'
idx_name(x, n = NULL, m = NULL)

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

## S3 method for class 'xseries'
idx_name(x, n = NULL, m = NULL)

Arguments

x

a dfidx, a idx or a xseries object

n

the index to be extracted (1 or 2, ignoring the nesting variables)

m

if > 1, a nesting variable

Value

if n is NULL, a named integer which gives the position and the name of the idx column in the dfidx object, otherwise, a character of length 1

Author(s)

Yves Croissant

Examples

mn <- dfidx(munnell, idx = c(region = "state", president = "year"))
# get the position of the idx column
idx_name(mn)
# get the name of the first index
idx_name(mn, 1)
# get the name of the second index
idx_name(mn, 2)
# get the name of the nesting variable for the second index
idx_name(mn, 2, 2)

dfidx documentation built on Aug. 8, 2025, 7:10 p.m.