Data frames with indexes
data frames for which observations are defined by two (potentialy nested) indexes and for which series have thefore a natural tabular representation
dfidx( data, idx = NULL, drop.index = TRUE, as.factor = NULL, pkg = NULL, fancy.row.names = FALSE, subset = NULL, idnames = NULL, shape = c("long", "wide"), choice = NULL, varying = NULL, sep = ".", opposite = NULL, levels = NULL, ranked = FALSE, ... )
data |
a data frame |
idx |
an index |
drop.index |
if |
as.factor |
should the indexes be coerced to factors ? |
pkg |
if set, the resulting |
fancy.row.names |
if |
subset |
a logical which defines a subset of rows to return |
idnames |
the names of the indexes |
shape |
either |
choice |
the choice |
varying, sep |
relevant for data sets in wide format, these arguments are passed to reshape |
opposite |
return the opposite of the series |
levels |
the levels for the second index |
ranked |
a boolean for ranked data |
... |
further arguments |
Indexes are stored as a data.frame
column in the
resulting dfidx
object
an object of class "dfidx"
Yves Croissant
data("TravelMode", package = "AER") # the first two columns contain the index TM1 <- dfidx(TravelMode) # explicitely indicate the two indexes using either a vector or a # list of two characters TM2 <- dfidx(TravelMode, idx = c("individual", "mode")) TM3 <- dfidx(TravelMode, idx = list("individual", "mode")) # rename one or both indexes TM3b <- dfidx(TravelMode, idnames = c(NA, "trmode")) # for balanced data (with observations ordered by the first, then # by the second index # use the name of the first index TM4 <- dfidx(TravelMode, idx = "individual", idnames = c("individual", "mode")) # or an integer equal to the cardinal of the first index TM5 <- dfidx(TravelMode, idx = 210, idnames = c("individual", "mode")) # Indicate the values of the second index using the levels argument TM5b <- dfidx(TravelMode, idx = 210, idnames = c("individual", "mode"), levels = c("air", "train", "bus", "car")) # Nesting structure for one of the index data("JapaneseFDI", package = "mlogit") JapaneseFDI <- dplyr::select(JapaneseFDI, 1:8) JP1b <- dfidx(JapaneseFDI, idx = list("firm", c("region", "country")), idnames = c("japf", "iso80")) # Data in wide format data("Fishing", package = "mlogit") Fi <- dfidx(Fishing, shape = "wide", varying = 2:9, idnames = c("chid", "alt"))
Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.