Skip to content

Help massaging big arrays

3 messages · Philip Rhoades, Thomas Lumley, Peter Dalgaard

#
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.
#
On Fri, 2 Aug 2002, Philip Rhoades wrote:

            
Call it X
X <- abs(X)
X[X<0.005] <- 0.005
Y<-matrix(ncol=5,nrow=1000)
for(i in 1:5)
    Y[,i] <- rowMeans(X[ ,1:(2^i)])
Y <- Z/Y
colMeans(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:
Except 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))