[R] How do I delete multiple blank variables from a data frame?

From: Rita Carreira <ritacarreira_at_hotmail.com>
Date: Fri, 18 Mar 2011 22:35:14 +0000

Dear List Members,I have 55 data frames, each of which with 272 variables and 267 observations. Some of these variables are blanks but the blanks are not the same for every data frame. I would like to write a procedure in which I import a data frame, see which variables are blank, and delete those variables. My data frames have variables named P1 to P136 and Q1 to Q136. I have a couple of questions regarding this issue: 1) Is a loop an efficient way to address this problem? If not, what are my alternatives and how do I implement them?2) I have been playing with a single data frame to try to figure out a way of having R go through the columns and see which ones it should delete. I have figured out how to delete rows with missing data (newdata <- na.omit(olddata)) but how do I do it for columns??? Thank you very much for your help and have a great weekend!

Rita ________________________________________ "If you think education is expensive, try ignorance"--Derek Bok

	[[alternative HTML version deleted]]

R-help_at_r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. Received on Sat 19 Mar 2011 - 01:15:25 GMT

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Sat 19 Mar 2011 - 02:00:22 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.

list of date sections of archive