[R] select rows with identical columns from a data frame
Sam Steingold
sds at gnu.org
Fri Jan 18 21:58:09 CET 2013
I can do
Reduce("==",f[complete.cases(f),])
but that creates an intermediate data frame which I would love to avoid
(to save memory).
> * Sam Steingold <fqf at tah.bet> [2013-01-18 15:53:21 -0500]:
>
> I have a data frame with several columns.
> I want to select the rows with no NAs (as with complete.cases)
> and all columns identical.
> E.g., for
>
>> f <- data.frame(a=c(1,NA,NA,4),b=c(1,NA,3,40),c=c(1,NA,5,40))
>> f
> a b c
> 1 1 1 1
> 2 NA NA NA
> 3 NA 3 5
> 4 4 40 40
>
> I want the vector TRUE,FALSE,FALSE,FALSE selecting just the first
> row because there all 3 columns are the same and none is NA.
>
> thanks!
--
Sam Steingold (http://sds.podval.org/) on Ubuntu 12.04 (precise) X 11.0.11103000
http://www.childpsy.net/ http://truepeace.org http://iris.org.il
http://www.PetitionOnline.com/tap12009/ http://ffii.org http://jihadwatch.org
War doesn't determine who's right, just who's left.
More information about the R-help
mailing list