Learn R Programming

plm (version 0.1-2)

pdata.frame: Data frame for panel data

Description

a data.frame with further attributes useful for panel data

Usage

pdata.frame(x,id,time=NULL,name=NULL)
## S3 method for class 'pdata.frame':
summary(object,...)
## S3 method for class 'summary.pdata.frame':
print(x,...)

Arguments

x
a data.frame (a pdata.frame for the print method),
object
a pdata.frame object,
id
the individual index
time
the time index
name
the name of the pdata.frame (the name of x if NULL),
...
further arguments.

Value

  • This function returns internally an object of class c("pdata.frame","data.frame"), which is a data.frame with three additional attributes :
  • indexesa list containing the names of the individual (id) and time (time) index variables,
  • pdima list containing the dimension of the pdata.frame (see pdim),
  • pvara list of two logical vectors indicating whether each variable has variations across individuals (id.var) and accross time periods (time.var) (see pvar).

Details

The observations are assumed to be sorted by individuals first and by time observations. id and time can be the names of the indexes contained in the data.frame if any. time may be omitted, in this case a new variable called "time" is added to the data.frame. For balanced panels, the argument id can be an integer. In this case, two new variables, "time" and "id" are added to the data.frame.

pdata.frame calls pdim to check for the individual and time dimensions of the panel and pvar to check for the individual and time variation of each variable.

All elements of a pdata.frame are of class pserie and have an attribute data which is the name of the pdata.frame. The print method is inherited from data.frame. A summary method is provided which add to the summary.data.frame method informations about the structure of the panel.

See Also

plm, pdim, pvar, pread.table.

Examples

Run this code
library(Ecdat)

#There are 595 individuals

data(Wages)
pdata.frame(Wages,595)

# Gasoline contains two variables which are individual and time indexes
# The pdata.frame is called gas
data(Gasoline)
pdata.frame(Gasoline,"country","year",name="gas")
summary(Gasoline)

# Hedonic is an unbalanced panel, townid is the individual index
data(Hedonic)
pdata.frame(Hedonic,"townid")

Run the code above in your browser using DataLab