Skip to content
Prev 296294 / 398498 Next

Converting a pdataframe into dataframe

On 2012-06-01 07:09, Apoorva Gupta wrote:
I assume that pdata.frame() is the function in package plm.
(You should say so.)

The solution depends a bit on just how similar your new data
frame should be to a.

If you don't mind the attributes attached to each variable in b,
then do just

   new.b <- as.data.frame(b)

which will invoke the as.data.frame.pdata.frame() function.

If you want to strip the attributes, then this should do:

   new.b <- lapply(b, function(x){attr(x, "index") <- NULL; x})

In either case, 'year' will still be a factor and you may
still wish to 'unfactor' it; see ?factor.

Peter Ehlers
--