pseriesfy: Turn all columns of a pdata.frame into class pseries.

View source: R/tool_transformations_collapse.R View source: R/tool_pdata.frame.R

pseriesfyR Documentation

Turn all columns of a pdata.frame into class pseries.

Description

This function takes a pdata.frame and turns all of its columns into objects of class pseries.

Usage

pseriesfy(x, ...)

Arguments

x

an object of class "pdata.frame",

...

further arguments (currently not used).

Details

Background: Initially created pdata.frames have as columns the pure/basic class (e.g., numeric, factor, character). When extracting a column from such a pdata.frame, the extracted column is turned into a pseries.

At times, it can be convenient to apply data transformation operations on such a pseriesfy-ed pdata.frame, see Examples.

Value

A pdata.frame like the input pdata.frame but with all columns turned into pseries.

See Also

pdata.frame(), as.list()

Examples

library("plm")
data("Grunfeld", package = "plm")
pGrun <- pdata.frame(Grunfeld[ , 1:4], drop.index = TRUE)
pGrun2 <- pseriesfy(pGrun) # pseriesfy-ed pdata.frame

# compare classes of columns
lapply(pGrun,  class)
lapply(pGrun2, class)

# When using with()
with(pGrun,  lag(value)) # dispatches to base R's lag() 
with(pGrun2, lag(value)) # dispatches to plm's lag() respect. panel structure

# When lapply()-ing 
lapply(pGrun,  lag) # dispatches to base R's lag() 
lapply(pGrun2, lag) # dispatches to plm's lag() respect. panel structure

# as.list(., keep.attributes = TRUE) on a non-pseriesfy-ed
# pdata.frame is similar and dispatches to plm's lag
lapply(as.list(pGrun, keep.attributes = TRUE), lag) 


ycroissant/plm documentation built on July 8, 2024, 3:59 a.m.