Skip to content
Prev 175005 / 398506 Next

same value in column-->delete

On Thu, Mar 26, 2009 at 12:15 PM, Duijvesteijn, Naomi
<Naomi.Duijvesteijn at ipg.nl> wrote:
Another, perhaps slightly more intuitive solution than Jim's would be
the following:

 x<-data.frame(id=c(1,2,3), snp1=c("A","G",
"G"),snp2=c("G","G","G"),snp3=c("G","G","A"))
is.monovalued<-function(df){
              sapply(df,function(x){
                            length(unique(x))==1
              })
}

monovaluedCols<-is.monovalued(x)
which(monovaluedCols)
x[!monovaluedCols]

/Gustaf