I have a data frame and I want to remove all columns with less than 1000 observations. The approach below works fine, but is there any more elegant solution?
vec <- numeric()
for(i in 1:ncol(dat))
{
if(length(dat[,i][!is.na(dat[,i])]) >= 1000)
vec <- c(vec, i)
}
dat <- dat[,vec]