dfidx | R Documentation |
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,
name,
position,
...
)
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 |
name |
name of the |
position |
position of the |
... |
further arguments |
Indexes are stored as a data.frame
column in the
resulting dfidx
object
an object of class "dfidx"
Yves Croissant
# 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")
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.