[R] I want to fill a column in with 0 or 1 depending on another columns input

kevin123 kevincorry123 at gmail.com
Mon Mar 5 20:56:15 CET 2012


 
This is a portion of my data frame

 MemberID    Specialty                 Surgery          Internal
1 42286978     Surgery                      NA                   NA
2 97903248     Internal                     NA                   NA
3  2759427      Internal                      NA                   NA      
4 73570559    Surgery                        NA                  NA

There are four columns. In the Specialty column there are two options
Surgery/Internal, These options have there own columns. 

I want to fill a column in with 0 or 1 depending on another columns input

I am finding it hard to figure out how to do the following:

    MemberID    Specialty                 Surgery          Internal
1  42286978     Surgery                      1                   0
2  97903248     Internal                     0                  1
3   2759427      Internal                      0                  1  
4  73570559    Surgery                        1                0

I would greatly appreciate any help

regards,

Kevin






--
View this message in context: http://r.789695.n4.nabble.com/I-want-to-fill-a-column-in-with-0-or-1-depending-on-another-columns-input-tp4447446p4447446.html
Sent from the R help mailing list archive at Nabble.com.



More information about the R-help mailing list