[R] Replacing a value in a dataframe

Bert Gunter gunter.berton at gene.com
Wed Nov 30 12:26:55 CET 2011


er... Uwe, shouldn't that be, e.g.

dataframe$Cheque <- as.integer(dataframe$Cheque)

## or building on Rolf's suggestion

dataframe <- within(dataframe, Cheque <- as.integer(Cheque))

While I am at it, is there any practical difference in efficiency
between these two approaches?

-- Bert


2011/11/30 Uwe Ligges <ligges at statistik.tu-dortmund.de>:
>
>
> On 30.11.2011 09:16, arunkumar1111 wrote:
>>
>> hi
>>
>> I have data like this in a dataframe
>>
>> Var  Value Cheque
>> X1    40    FALSE
>> X2    20    FALSE
>> X3    28    TRUE
>>
>> I want to replace it FLASE  with 0 and TRUE with 1.
>>
>> is there any method by which i can do without using LOOP
>
>
>
> dataframe$Cheque <- as.integer(Cheque)
>
> Uwe Ligges
>
>
>>
>> --
>> View this message in context:
>> http://r.789695.n4.nabble.com/Replacing-a-value-in-a-dataframe-tp4122188p4122188.html
>> Sent from the R help mailing list archive at Nabble.com.
>>
>> ______________________________________________
>> R-help at 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.
>
>
> ______________________________________________
> R-help at 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.



-- 

Bert Gunter
Genentech Nonclinical Biostatistics

Internal Contact Info:
Phone: 467-7374
Website:
http://pharmadevelopment.roche.com/index/pdb/pdb-functional-groups/pdb-biostatistics/pdb-ncb-home.htm



More information about the R-help mailing list