[prev in list] [next in list] [prev in thread] [next in thread] 

List:       r-help
Subject:    [R] newbie question about index
From:       z s <flyhyena () yahoo ! com ! cn>
Date:       2006-08-31 14:41:27
Message-ID: 20060831144127.10844.qmail () web15610 ! mail ! cnb ! yahoo ! com
[Download RAW message or body]

Hi,

  I am trying to convert a variable a = sample(1:3,100,rep = T) represents choices \
into a 3X100 dummy varible b with corresponding element set to 1 otherwise 0. eg.

a: 1 3 2 1 2 3 1 1....

b: 1 0 0 1 0 0 1 1..
    0 0 1 0 1 0 0 0...
    0 1 0 0 0 1 0 0...

 Is there something like b[a] =1 existing? I could not figure this out myself.

 		
---------------------------------
 Mp3·è¿ñËÑ-Ð ¸èÈȸè¸ßËÙÏ    
	[[alternative HTML version deleted]]



______________________________________________
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic