Re: [R] select columns array2 not equal to 10

2011-08-22 Thread Changbin Du
Thanks, Michael! You have an heart of gold! Appreciated! On Mon, Aug 22, 2011 at 10:53 AM, R. Michael Weylandt < michael.weyla...@gmail.com> wrote: > The different lengths work because R recycles values whenever you try to do > a binary operation on things of different lengths: in essence, R co

Re: [R] select columns array2 not equal to 10

2011-08-22 Thread R. Michael Weylandt
The different lengths work because R recycles values whenever you try to do a binary operation on things of different lengths: in essence, R copies 10 however many times needed to make something that has the right length for an elementwise comparison with x.** If you did something like x != c(1,1

Re: [R] select columns array2 not equal to 10

2011-08-22 Thread Changbin Du
HI, Michael, Sorry for my numb, I have one more question. When you use function(x){any (x != 10), here x is a vector, x!=10 will give a vector of logical value, right? If it is, how can vector be compared to a scale, 10 in this case? Thanks! On Mon, Aug 22, 2011 at 10:16 AM, R. Michael Weyl

Re: [R] select columns array2 not equal to 10

2011-08-22 Thread Changbin Du
THANKS SO MUCH, Michael! Appreciated! On Mon, Aug 22, 2011 at 10:16 AM, R. Michael Weylandt < michael.weyla...@gmail.com> wrote: > This isn't the most beautiful code, but I think it should work for you: > > # Some sample data > M = > cbind(matrix(rnorm(10),ncol=2),matrix(sample(c(10,1),15,repl

Re: [R] select columns array2 not equal to 10

2011-08-22 Thread R. Michael Weylandt
This isn't the most beautiful code, but I think it should work for you: # Some sample data M = cbind(matrix(rnorm(10),ncol=2),matrix(sample(c(10,1),15,replace=T),ncol=3)) colnames(M) = c("Thing1","Thing2",paste("array",1:3,sep="")) colsToCheck = grepl("array",colnames(M)) # Isolate the "array" co

Re: [R] select columns array2 not equal to 10

2011-08-22 Thread Changbin Du
HI, Michael, What I want to do is remove all the rows, for which array1, array2, ..array15 are all equal to 10. I want to keep all the rows at least one of the array variables are not equal to 10. sorry for the confusion. On Mon, Aug 22, 2011 at 9:52 AM, R. Michael Weylandt < michael.weyla..

Re: [R] select columns array2 not equal to 10

2011-08-22 Thread R. Michael Weylandt
"I want to select the array columns that are not equal to 10." is ambiguous to me. Just to clarify, do you want to simply drop the column named array10 or do you want to check each column for having one/all 10's as values and drop based on that test? Michael On Mon, Aug 22, 2011 at 12:35 PM, Cha

[R] select columns array2 not equal to 10

2011-08-22 Thread Changbin Du
Dear R community, I have a data set like the following: probe_name chr_id position array1 array2 array3 array4 array5 array6 array7 1C-3 10 16566949 10 10 10 10 10 10 10 2C-3AAAB 17 33478940 10 10 10 10 10 10 10 3C-3AAAC