Skip to content
Prev 12137 / 398502 Next

a little probleme

R> x <- c(1,2,3,3,4,4,5,6)
R> sapply(unique(x), fun <- function(a) x ==  a)
      [,1]  [,2]  [,3]  [,4]  [,5]  [,6]
[1,]  TRUE FALSE FALSE FALSE FALSE FALSE
[2,] FALSE  TRUE FALSE FALSE FALSE FALSE
[3,] FALSE FALSE  TRUE FALSE FALSE FALSE
[4,] FALSE FALSE  TRUE FALSE FALSE FALSE
[5,] FALSE FALSE FALSE  TRUE FALSE FALSE
[6,] FALSE FALSE FALSE  TRUE FALSE FALSE
[7,] FALSE FALSE FALSE FALSE  TRUE FALSE
[8,] FALSE FALSE FALSE FALSE FALSE  TRUE

which is as good as 0, 1 ;-)

Torsten
-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
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
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._