[R] Help massaging big arrays
Thomas Lumley
tlumley at u.washington.edu
Thu Aug 1 17:15:35 CEST 2002
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 floats
Call 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.0005
X[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 32
Y<-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 array
Y <- Z/Y
> - Produce 5 means of the 5 columns of array #5
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
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
More information about the R-help
mailing list