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)
Run the code above in your browser using DataLab