(i want change G3 and G2 to variable tke all elements in rows) (truth[(truth[, 1]=="G3" & truth[, 2]=="G2") | (truth[, 1]=="G2" & truth[, 2]=="G3"), 3]<-1

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

(i want change G3 and G2 to variable tke all elements in rows) (truth[(truth[, 1]=="G3" & truth[, 2]=="G2") | (truth[, 1]=="G2" & truth[, 2]=="G3"), 3]<-1

R help mailing list-2
helloout<-read.csv("outbr.csv")truth<-out[,seq(1,2)]for example :
 If row1= G1 and row2=G2 , and row 1 = G2 and row 2= G1,make G3=1 # note G1 and G2 are values from 1 to 2000 #if this happend add to thrid column in truth 1 otherwise add 0 as in statment follow
truth<-cbind(as.character(truth[,1]),as.character(truth[,2])             ,as.data.frame(rep(0,,dim(out)[1])));#here just G2 and G3, i want make loop to cam[are all values from G1 to G2000 
truth[(truth[,1]=="G3" & truth[,2]=="G2") | (truth[,1]=="G2" & truth[,2]=="G3"),3]<-1 ###############################3(Simply they regulate the other. If element A is in the first group , and it is related to element B in the second group , and element B also in  in the first group , and it is related to element A(the same element  in the first group)  in the second group , we write 1 and otherwise 0.
this the distination result:
I want this result
G1 G2  G3 D    B    1 B   D     1 A    D    0 B    A    1B    C    0A   B    1

        [[alternative HTML version deleted]]

______________________________________________
[hidden email] mailing list -- To UNSUBSCRIBE and more, see
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.
Reply | Threaded
Open this post in threaded view
|

Re: (i want change G3 and G2 to variable tke all elements in rows) (truth[(truth[, 1]=="G3" & truth[, 2]=="G2") | (truth[, 1]=="G2" & truth[, 2]=="G3"), 3]<-1

PIKAL Petr
Hi

You still fail to send your message in plain text, so it is unreadable.

If I managed to decipher it correctly what you wanted you probably could set 2
related logical expression and considering that FALSE is 0 and TRUE is 1 you
get desired result.

Cheers
Petr

> -----Original Message-----
> From: R-help <[hidden email]> On Behalf Of Hesham A. AL-
> bukhaiti via R-help
> Sent: Monday, September 7, 2020 5:49 AM
> To: [hidden email]
> Subject: [R] (i want change G3 and G2 to variable tke all elements in rows)
> (truth[(truth[, 1]=="G3" & truth[, 2]=="G2") | (truth[, 1]=="G2" & truth[,
> 2]=="G3"), 3]<-1
>
> helloout<-read.csv("outbr.csv")truth<-out[,seq(1,2)]for example :
>  If row1= G1 and row2=G2 , and row 1 = G2 and row 2= G1,make G3=1 # note
> G1 and G2 are values from 1 to 2000 #if this happend add to thrid column in
> truth 1 otherwise add 0 as in statment follow
> truth<-
> cbind(as.character(truth[,1]),as.character(truth[,2])
> ,as.data.frame(rep(
> 0,,dim(out)[1])));#here just G2 and G3, i want make loop to cam[are all
> values
> from G1 to G2000 truth[(truth[,1]=="G3" & truth[,2]=="G2") |
> (truth[,1]=="G2"
> & truth[,2]=="G3"),3]<-1 ###############################3(Simply they
> regulate the other. If element A is in the first group , and it is related
> to
> element B in the second group , and element B also in  in the first group ,
> and
> it is related to element A(the same element  in the first group)  in the
> second
> group , we write 1 and otherwise 0.
> this the distination result:
> I want this result
> G1 G2  G3 D    B    1 B   D     1 A    D    0 B    A    1B    C    0A   B
> 1
>
> [[alternative HTML version deleted]]
>
> ______________________________________________
> [hidden email] mailing list -- To UNSUBSCRIBE and more, see
> 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.

______________________________________________
[hidden email] mailing list -- To UNSUBSCRIBE and more, see
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.