[R] conditional Dataframe filling

Camilo Mora cmora at dal.ca
Wed Mar 27 09:31:47 CET 2013


Hi everyone:

This may be trivial but I just have not been able to figure it out.

Imagine the following dataframe:
a     b     c     d
TRUE  TRUE  TRUE  TRUE
FALSE FALSE FALSE TRUE
FALSE  TRUE  FALSE  FALSE

I would like to create a new dataframe, in which TRUE gets 0 but if  
false then add 1 to the cell to the left. So the results for the  
example above should be something like:

a     b     c     d
0     0     0     0
1     2     3     0
1     0     1     2

I wonder if you may know?.

Thanks,

Camilo




Camilo Mora, Ph.D.
Department of Geography, University of Hawaii
Currently available in Colombia
Phone:   Country code: 57
          Provider code: 313
          Phone 776 2282
          From the USA or Canada you have to dial 011 57 313 776 2282
http://www.soc.hawaii.edu/mora/



More information about the R-help mailing list