Re: [R] balanced panel data

2011-05-19 Thread Cecilia Carmo
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

Re: [R] balanced panel data

2011-05-19 Thread Scott Chamberlain
# 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

[R] balanced panel data

2011-05-19 Thread Cecilia Carmo
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