Learn R Programming

plm (version 0.1-2)

papply: Conditional operation for panel data

Description

Apply an operation to a vector or a matrix for panel data.

Usage

papply(x, ...)
## S3 method for class 'pserie':
papply(x,func,effect="individual", ...)
## S3 method for class 'matrix':
papply(x,func,cond, ...)
## S3 method for class 'default':
papply(x,func,cond, ...)

Arguments

x
a numeric vector or matrix,
func
the function to apply to x,
cond
a vector containing the conditional variable,
effect
the effect for the papply transformation (one of individual or time),
...
further arguments.

Value

  • a vector (or a matrix) of the same dimension as the first argument.

Examples

Run this code
library(Ecdat)
data(Grunfeld)
pdata.frame(Grunfeld,"firm","year")
papply(Grunfeld$inv,mean)
X <- model.matrix(~value+capital-1,Grunfeld)
papply(X,mean,Grunfeld$firm)

Run the code above in your browser using DataLab