I have a data.frame
with 571 observations of 156 variables. I am interested in keeping all 156 variables; however, I only need complete observations for 7 of these variables.
By using:
> nrow(na.omit(subset(finaldata, select = c("h_egfr_cystc96", "child_age96", "smoke_inside2T", "SES_3cat2T", "X_ZBFA96", "log2Tblood", "sexo_h00"))))
I learn that there are 453 observations that have complete information for these 7 variables.
How can I create a new data.frame
that will have 453 observations of 156 variables, with complete information for my 7 variables of interest?
I suspect that complete.cases
will be useful, but I am not sure how to apply it here.
Any ideas? Thank you in advance for the help!