[R] a little probleme

Olivier Martin olivier.martin at inrialpes.fr
Wed Jul 4 13:49:50 CEST 2001


Hi all,

i would like to find the best way to resolve the following problem.
Suppoose i have a vector x of length N with k different elements.
length(x)=N
u<-unique(x)
length(u)=k

I would like to get a matrix M with k rows and N columns such that:
in each line i (i=1,...,k), which(x%in%u[i]) is equal to 1 and 0 else.

Thanks for your help.
Olivier


--
-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
Olivier MARTIN               phone: (33) 04 76 61 53 55
Projet IS2                               06 08 67 93 42
INRIA Rhone-Alpes            fax  : (33) 04 76 61 54 77
655, Av. de l'Europe
Montbonnot                  e-mail:olivier.martin at inrialpes.fr
38334 Saint Ismier cedex
-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-


-------------- next part --------------
An HTML attachment was scrubbed...
URL: https://stat.ethz.ch/pipermail/r-help/attachments/20010704/e33482d5/attachment.html


More information about the R-help mailing list