It works!
Thank you.
CecÃlia
De: Scott Chamberlain [mailto:scttchamberla...@gmail.com]
Enviada: quinta-feira, 19 de Maio de 2011 13:40
Para: Cecilia Carmo
Cc: r-help@r-project.org
Assunto: Re: [R] balanced panel data
# If you know how many years are needed you could do this
# If you know how many years are needed you could do this
makenewtable <- function(x, years) {
xlist <- split(x, x$firm)
new <- list()
dat <- lapply(xlist, function(z) if(length(unique(z$year)) == years) {new <- z}
)
dat_ <- do.call(rbind, dat)
return(dat_)
}
makenewtable(finaldata, 5)
Scott
On
I have a dataframe with many firm-year observations and many variables.
Not all firms have information for all the years.
I want another dataframe with only those firms that have information all
years.
This is, I want a balanced panel data, but with the maximum number of years.
In my reprocuci
3 matches
Mail list logo