
Last chance! 50% off unlimited learning
Sale ends in
pdata.frame(x, index = NULL, drop.index = FALSE, row.names = TRUE, stringsAsFactors = default.stringsAsFactors())
"["(x, i, j, drop)
"[["(x, y)
"$"(x, y)
"print"(x, ...)
"as.data.frame"(x, row.names = NULL, optional = FALSE, ...)
"as.list"(x, keep.attributes = FALSE, ...)
data.frame
for the pdata.frame
function and a
pdata.frame
for the methods,Extract
,Extract
,data.frame
,Extract
,as.data.frame
,NULL
or logical, indicates whether ``fancy'' row names (a combination of individual
index and time index) are to be added to the returned (p)data.frame (NULL
and FALSE
have the same meaning),pdata.frame
object: this is a data.frame
with an
index
attribute which is a data.frame
with two
variables, the individual and the time indexes, both being factors.
The resulting pdata.frame is sorted by the individual index, then
by the time index. Any constant columns and all-NA columns are dropped.
index
argument indicates the dimensions of the panel. It can be:
The "[["
and "$"
extract
a series from the pdata.frame
. The "index"
attribute is
then added to the series and a class attribute "pseries"
is
added. The "["
method behaves as for data.frame
, except
that the extraction is also applied to the index
attribute.
as.data.frame
removes the index from the pdata.frame
and
adds it to each column.
as.list
behaves by default identical to as.list.data.frame
which means it drops the attributes specific to a pdata.frame; if a list of pseries
is wanted, the attribute keep.attributes
can to be set to TRUE
. This also
makes lapply
work as expected on a pdata.frame (see also Examples).
pdim
to check the dimensions of a 'pdata.frame' (and other objects),
pvar
to check for each variable if it varies cross-sectionally and over time.
To check if the time periods are consecutive per individual, see is.pconsecutive
.
# Gasoline contains two variables which are individual and time indexes
data("Gasoline", package = "plm")
Gas <- pdata.frame(Gasoline, index = c("country", "year"), drop = TRUE)
# Hedonic is an unbalanced panel, townid is the individual index
data("Hedonic", package = "plm")
Hed <- pdata.frame(Hedonic, index = "townid", row.names = FALSE)
# In case of balanced panel, it is sufficient to give number of individuals
# data set 'Wages' is organized as a stacked time series
data("Wages", package = "plm")
Wag <- pdata.frame(Wages, 595)
# lapply on a pdata.frame by making it a list of pseries first
lapply(as.list(Wag[ , c("ed", "lwage")], keep.attributes = TRUE), lag)
Run the code above in your browser using DataLab