you can use 'apply': apply(A[, 48:243], 1, median)
On Nov 12, 2007 3:30 PM, affy snp <[EMAIL PROTECTED]> wrote: > Thanks Jim. It is way simple. Great. > Is there any function like rowMedians() which > could take the median value across samples? > > Allen > > On Nov 12, 2007 3:10 PM, jim holtman <[EMAIL PROTECTED]> wrote: > > > Try something like this: > > > > myAvg <- rowMeans(A[,48:243]) > > B <- A[1:47,] / myAvg > > > > > > On Nov 12, 2007 1:37 PM, affy snp <[EMAIL PROTECTED]> wrote: > > > Dear list, > > > > > > Hi! I have a table A, 238304 rows and 243 columns (representing > > > samples). First of all, I would like to pool a group of samples > > > from 48th column to 243rd column and take the average across > > > them and make a single column,saying as the reference column. > > > > > > Second, I want to use each column of first 47 columns in table > > > A divided by the reference column and end up with a new table > > > B with 238304 rows and 47 columns. > > > > > > Is there any simple code which especially could do sth like > > > reference_column<-(A[,48]+A[,49]+...A[,243])/196 > > > and B<-A[,1:47]/reference_column? > > > > > > Thank you very much for your help! > > > > > > Best, > > > Allen > > > > > > ______________________________________________ > > > [email protected] mailing list > > > https://stat.ethz.ch/mailman/listinfo/r-help > > > PLEASE do read the posting guide > > > http://www.R-project.org/posting-guide.html > > > and provide commented, minimal, self-contained, reproducible code. > > > > > > > > > > > -- > > Jim Holtman > > Cincinnati, OH > > +1 513 646 9390 > > > > What is the problem you are trying to solve? > > > -- Jim Holtman Cincinnati, OH +1 513 646 9390 What is the problem you are trying to solve? ______________________________________________ [email protected] mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.

