Become an expert in R — Interactive courses, Cheat Sheets, certificates and more!
Get Started for Free

idx_name

Get the names of the indexes


Description

This function extract the names of the indexes 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 posititon of the idx column in the dfidx object, otherwise, a character of length 1

Author(s)

Yves Croissant

Examples

data("JapaneseFDI", package = "mlogit")
JapaneseFDI <- dplyr::select(JapaneseFDI, 1:8)
JP1b <- dfidx(JapaneseFDI, idx = list("firm", c("region", "country")),
idnames = c("japf", "iso80"))
# get the position of the idx column
idx_name(JP1b)
# get the name of the first index
idx_name(JP1b, 1)
# get the name of the second index
idx_name(JP1b, 2)
# get the name of the nesting variable for the second index
idx_name(JP1b, 2, 2)

dfidx

Indexed Data Frames

v0.0-4
GPL (>= 2)
Authors
Yves Croissant [aut, cre]
Initial release
2021-02-02

We don't support your browser anymore

Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.