Hi all, I hope someone can give me some quick pointers - it would take me ages to work this out from scratch - I want to: - From an array - 32 cols x 1000 rows of small floats - Produce a second array from the first where the all numbers have an abs fn applied to them (to get rid of the neg numbers) - Produce a third array from the second where all numbers less than 0.0005 are converted to 0.0005 - Produce a fourth array (5x1000) from the third where the first number in the row is the mean of the first two numbers of array #3, the second number is the mean of the first 4 numbers, 3rd mean of 8, 4th mean of 16, 5th mean of 32 - Produce a fifth (5x1000) array by dividing array #4 into another 5x1000 array - Produce 5 means of the 5 columns of array #5 Any help greatly appreciated. Regards, Phil. -- Philip Rhoades Pricom Pty Limited (ACN 003 252 275) GPO Box 3411 Sydney NSW 2001 Australia Mobile: +61:0411-185-652 Fax: +61:2:8923-5363 E-mail: pri at chu.com.au -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html Send "info", "help", or "[un]subscribe" (in the "body", not the subject !) To: r-help-request at stat.math.ethz.ch _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
On Fri, 2 Aug 2002, Philip Rhoades wrote:> Hi all, > > I hope someone can give me some quick pointers - it would take me ages > to work this out from scratch - I want to: > > - From an array - 32 cols x 1000 rows of small floatsCall it X> - Produce a second array from the first where the all numbers have an > abs fn applied to them (to get rid of the neg numbers)X <- abs(X)> - Produce a third array from the second where all numbers less than > 0.0005 are converted to 0.0005X[X<0.005] <- 0.005> - Produce a fourth array (5x1000) from the third where the first number > in the row is the mean of the first two numbers of array #3, the second > number is the mean of the first 4 numbers, 3rd mean of 8, 4th mean of > 16, 5th mean of 32Y<-matrix(ncol=5,nrow=1000) for(i in 1:5) Y[,i] <- rowMeans(X[ ,1:(2^i)])> - Produce a fifth (5x1000) array by dividing array #4 into another > 5x1000 arrayY <- Z/Y> - Produce 5 means of the 5 columns of array #5colMeans(Y) -thomas -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html Send "info", "help", or "[un]subscribe" (in the "body", not the subject !) To: r-help-request at stat.math.ethz.ch _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
Philip Rhoades <pri at chu.com.au> writes:> Hi all, > > I hope someone can give me some quick pointers - it would take me ages > to work this out from scratch - I want to: > > - From an array - 32 cols x 1000 rows of small floats > > - Produce a second array from the first where the all numbers have an > abs fn applied to them (to get rid of the neg numbers) > > - Produce a third array from the second where all numbers less than > 0.0005 are converted to 0.0005 > > - Produce a fourth array (5x1000) from the third where the first > number in the row is the mean of the first two numbers of array #3, > the second number is the mean of the first 4 numbers, 3rd mean of 8, > 4th mean of 16, 5th mean of 32 > > - Produce a fifth (5x1000) array by dividing array #4 into another > 5x1000 array > > - Produce 5 means of the 5 columns of array #5Except for item 4, these are trivial and quite fundamental. You'd be better off looking into Ch.5 of "An Introduction to R" than to have people write down the solution for you. Item 4 is a little tricky: sapply(2^(1:5), function(i)apply(m[,1:i],1,mean)) -- O__ ---- Peter Dalgaard Blegdamsvej 3 c/ /'_ --- Dept. of Biostatistics 2200 Cph. N (*) \(*) -- University of Copenhagen Denmark Ph: (+45) 35327918 ~~~~~~~~~~ - (p.dalgaard at biostat.ku.dk) FAX: (+45) 35327907 -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html Send "info", "help", or "[un]subscribe" (in the "body", not the subject !) To: r-help-request at stat.math.ethz.ch _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._