Thanks, David!

On Thu, Feb 24, 2011 at 11:30 AM, David Winsemius <dwinsem...@comcast.net>wrote:

>
> On Feb 24, 2011, at 1:23 PM, Changbin Du wrote:
>
> HI, Dear R community,
>>
>> I try to create 100 dummy variables like the following:
>>
>> ack$id_1 <- (ack$ID==1)*1
>> ack$id_2 <- (ack$ID==2)*1
>> ..
>> .
>> ack$id_100 <- (ack$ID==100)*1
>>
>>
>> I used the following codes:
>>
>> for(i in 1:100){
>>             ack$id_[i] <- (ack$ID==i)*1
>>
>
> You are creating only one new column named ack$id_
>
> Putting the "[" operator with a numeric argument after does not name a new
> column.
>
>
>                    }
>> But only one column is created, can anyone help me?
>>
>
> If I tell you how to do that I would only be hurting you. You should be
> using factors. The modeling functions should all be capable of accepting
> them and if you are writing your own then it seems only sensible that you
> follow their example.
>
>
>>
>
> --
>
> David Winsemius, MD
> West Hartford, CT
>
>


-- 
Sincerely,
Changbin
--

Changbin Du
DOE Joint Genome Institute
Bldg 400 Rm 457
2800 Mitchell Dr
Walnut Creet, CA 94598
Phone: 925-927-2856

        [[alternative HTML version deleted]]

______________________________________________
R-help@r-project.org 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.

Reply via email to