[R] check and verify

Bert Gunter gunter.berton at gene.com
Tue Aug 28 10:11:42 CEST 2012


?ifelse
Probably most simply used via ?with, e.g.l

result1 <- with(test, ifelse(A == C,E,0)) ## Similarly for B and D

-- Bert

On Mon, Aug 27, 2012 at 10:00 PM, Sapana Lohani <lohani.sapana at ymail.com> wrote:
> Hi,
>
>
> I have 6 columns in my dataframe (test)
>
> A B C D E F
> a b c d 40 30
> a f a b 20 10
> x m y m 50 30
>
> If character value in column A matches with that in column C, it gets the percentage in column E, similarly if value in column B matches the value in D, it gets the percentage in F column. If it doesn't match, it gets 0 percentage.
>
>
> How can I do that ?
>
> thanks
>
>         [[alternative HTML version deleted]]
>
> ______________________________________________
> 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