Skip to content
Prev 66230 / 398503 Next

Remove columns from data-frame

try this:

dat <- data.frame(y=rnorm(100), f1=sample(c("Yes", "No"), 100, TRUE), 
f2=rep("Yes", 100), f3=rep("No", 100))
#############
dat[!sapply(dat, function(x) all(x==x[1]))]

I hope it helps.

Best,
Dimitris

----
Dimitris Rizopoulos
Ph.D. Student
Biostatistical Centre
School of Public Health
Catholic University of Leuven

Address: Kapucijnenvoer 35, Leuven, Belgium
Tel: +32/16/336899
Fax: +32/16/337015
Web: http://www.med.kuleuven.ac.be/biostat/
     http://www.student.kuleuven.ac.be/~m0390867/dimitris.htm

----- Original Message ----- 
From: "Maciej Blizi?ski" <m.blizinski at wsisiz.edu.pl>
To: <r-help at stat.math.ethz.ch>
Sent: Monday, March 21, 2005 11:12 AM
Subject: [R] Remove columns from data-frame