30
#or
within(test,{new_column_2<-(as.character(B)==as.character(D))*F;new_column_1<-(as.character(A)==as.character(C))*E})
#A B C D E F new_column_1 new_column_2
#1 a b c d 40 30 0 0
#2 a f a b 20 10 20 0
#3 x m y m 50 30 0
0 30
A.K.
From: Sapana Lohani
To: arun
Sent: Tuesday, August 28, 2012 5:40 PM
Subject: Re: [R] check and verify
Hi, may be i was not clear when I made this query before.
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
I want a n
0 a b 20 10
#3 0 30 y m 50 30
A.K.
- Original Message -
From: Sapana Lohani
To: R help
Cc:
Sent: Tuesday, August 28, 2012 1:00 AM
Subject: [R] check and verify
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
?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 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 3
Hi
> -Original Message-
> From: r-help-boun...@r-project.org [mailto:r-help-bounces@r-
> project.org] On Behalf Of Sapana Lohani
> Sent: Tuesday, August 28, 2012 7:01 AM
> To: R help
> Subject: [R] check and verify
>
> Hi,
>
>
> I have 6 columns in my
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
6 matches
Mail list logo