# the first two columns contain the index
mn <- dfidx(munnell)
# explicitely indicate the two indexes using either a vector or a
# list of two characters
mn <- dfidx(munnell, idx = c("state", "year"))
mn <- dfidx(munnell, idx = list("state", "year"))
# rename one or both indexes
mn <- dfidx(munnell, idnames = c(NA, "period"))
# for balanced data (with observations ordered by the first, then
# by the second index
# use the name of the first index
mn <- dfidx(munnell, idx = "state", idnames = c("state", "year"))
# or an integer equal to the cardinal of the first index
mn <- dfidx(munnell, idx = 48, idnames = c("state", "year"))
# Indicate the values of the second index using the levels argument
mn <- dfidx(munnell, idx = 48, idnames = c("state", "year"),
levels = 1970:1986)
# Nesting structure for one of the index
mn <- dfidx(munnell, idx = c(region = "state", president = "year"))
# Data in wide format
mn <- dfidx(munnell_wide, idx = c(region = "state"),
varying = 3:36, sep = "_", idnames = c(NA, "year"))
# Customize the name and the position of the `idx` column
#dfidx(munnell, position = 3, name = "index")
Run the code above in your browser using DataLab