I have a dataframe with company quarterly data and have this question:
How can I retain records for only those companies with 4 quarters of data (as companies sometimes
Here is the code that can help you:
library(data.table) data<-data.table( year, qtr, company, IQ, REVQ, AssetQ, CashQ) fullyr <- data[,.(len=.N),by=.(year)][len == 4] data <- data[year %in% fullyr$year]
Requesting you to provide the code you have tried for solution next time :)