Re: [R] same value in column-->delete

2009-03-26 Thread Uwe Ligges
Patrizio Frederic wrote: this works which.is.not.unique <- apply(x,2,function(x)ifelse(length(unique(x))==1,F,T)) x[,which.is.not.unique] or you simplify that idea and say x[, apply(x, 2, function(x) length(unique(x)) > 1)] Uwe Ligges patrizio 2009/3/26 Duijvesteijn, Naomi : Hi R

Re: [R] same value in column-->delete

2009-03-26 Thread Patrizio Frederic
this works which.is.not.unique <- apply(x,2,function(x)ifelse(length(unique(x))==1,F,T)) x[,which.is.not.unique] patrizio 2009/3/26 Duijvesteijn, Naomi : > >   Hi Readers, > > >   I have a question. > > >   I have a large dataset and want to throw away columns that have the same >   value in the

Re: [R] same value in column-->delete

2009-03-26 Thread Gustaf Rydevik
On Thu, Mar 26, 2009 at 12:15 PM, Duijvesteijn, Naomi wrote: > >   Hi Readers, > > >   I have a question. > > >   I have a large dataset and want to throw away columns that have the same >   value in the column itself and I want to know which column this was. > > >   For example > >   > x<-data.fr

Re: [R] same value in column-->delete

2009-03-26 Thread jim holtman
Try this: > x id snp1 snp2 snp3 1 1AGG 2 2GGG 3 3GGA > str(x) 'data.frame': 3 obs. of 4 variables: $ id : num 1 2 3 $ snp1: Factor w/ 2 levels "A","G": 1 2 2 $ snp2: Factor w/ 1 level "G": 1 1 1 $ snp3: Factor w/ 2 levels "A","G": 2 2 1 > # test fo

[R] same value in column-->delete

2009-03-26 Thread Duijvesteijn, Naomi
Hi Readers, I have a question. I have a large dataset and want to throw away columns that have the same value in the column itself and I want to know which column this was. For example > x<-data.frame(id=c(1,2,3), snp1=c("A","G", "G"),snp2=c("G","G","G"),snp3=c("G","G",