[R] Changing sign of columns and values

hanatezera h@n@tezer@ @end|ng |rom gm@||@com
Sun Jun 12 01:11:15 CEST 2022


Dear jim thanks for your help! I want to change also the value of OA and EF simultaneously.For instance i am looking the datamydf IDnumber OA EA  beta1        1  A  C  0.0502        2  G  A 0.0983        3  T   G 0.789Best, Hana                 
-------- Original message --------From: Jim Lemon <drjimlemon using gmail.com> Date: 6/12/22  1:59 AM  (GMT+03:00) To: hanatezera <hanatezera using gmail.com>, r-help mailing list <r-help using r-project.org> Subject: Re: [R] Changing sign of columns and values Hi Hana,I think this is what you want:# first read in your examplemydf<-read.table(text="IDnumber  OA  EA  beta1   C       A       -0.052   G        A        0.0983   G        T        -0.789",header=TRUE,stringsAsFactors=FALSE)# check itmydf IDnumber OA EA   beta1        1  C  A -0.0502        2  G  A  0.0983        3  G  T -0.789# change values of mydf$beta to absolute valuesmydf$beta<-abs(mydf$beta)mydf IDnumber OA EA  beta1        1  C  A 0.0502        2  G  A 0.0983        3  G  T 0.789JimOn Sun, Jun 12, 2022 at 8:27 AM hanatezera <hanatezera using gmail.com> wrote:>> I have the following data set in data frameIDnumber  OA  EA  beta1                         C       A       -0.052                         G        A        0.0983                          G        T        -0.789....I want to change the sign of negative beta. If the negative value change to postive i want to switch its EA and OA.My desire result will beIDnumber  OA  EA  beta1                         A      C     0.052                         G        A        0.0983                          T         G        0.789....Any one can help me with r codes? kind regards,Hana>         [[alternative HTML version deleted]]>> ______________________________________________> R-help using r-project.org 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.
	[[alternative HTML version deleted]]



More information about the R-help mailing list