[R] "mystic" apply ?

About this list Date view Thread view Subject view Author view Attachment view

From: Christian Schulz (ozric@web.de)
Date: Wed 11 Dec 2002 - 06:58:07 EST


Message-id: <003f01c2a086$835df570$8f3f07d5@c5c9i0>

hi,

have anybody a suggestion why this function
works only for a vector correct.
When i'm using apply(data,2,fuzzy) i have the columns
stacked (i.e. dim(x) =1000,4 should after the function 1000,8
instead is 2000,4) - for single vector it's ok.

fuzzy <- function (x)
{
    fuz.x <- cbind(x, x)
    min <- quantile(x, 0.20)
    max <- quantile(x, 0.80)
    fuz.x[x >= max, 1] <- 1
    fuz.x[x >= max, 2] <- 0
    fuz.x[x <= min, 1] <- 0
    fuz.x[x <= min, 2] <- 1
    fuz.x[x > min & x < max, 1] <- (x[x > min & x < max] - min)/(max - min)
    fuz.x[x > min & x < max, 2] <- (max - x[x > min & x < max])/(max - min)
    fuz.x
}

______________________________________________
R-help@stat.math.ethz.ch mailing list
http://www.stat.math.ethz.ch/mailman/listinfo/r-help


About this list Date view Thread view Subject view Author view Attachment view

This archive was generated by hypermail 2.1.3 : Tue 01 Jun 2004 - 09:31:51 EST