Re: [R] Moving 2nd column into 1st column using R

2019-09-11 Thread Martin Møller Skarbiniks Pedersen
On Tue, 10 Sep 2019 at 04:20, smart hendsome via R-help < r-help@r-project.org> wrote: > > Hi R-user, > I have a problem regarding R. How can I move my 2nd column into 1st column. For example I have data as below: > mydf <- data.frame(matrix(1:6, ncol = 2)) > mydf > X1 X2 1 4 2 5 3

Re: [R] Moving 2nd column into 1st column using R

2019-09-11 Thread PIKAL Petr
Or maybe use stack stack(mydf) Cheers Petr > -Original Message- > From: R-help On Behalf Of Jim Lemon > Sent: Tuesday, September 10, 2019 6:34 AM > To: smart hendsome ; r-help mailing list h...@r-project.org> > Subject: Re: [R] Moving 2nd column into 1st column us

Re: [R] Moving 2nd column into 1st column using R

2019-09-09 Thread Jim Lemon
Hi Zuhri, Try: mydf<-mydf[,c(2,1)] You might be surprised. Jim On Tue, Sep 10, 2019 at 12:20 PM smart hendsome via R-help wrote: > > Hi R-user, > I have a problem regarding R. How can I move my 2nd column into 1st column. > For example I have data as below: > mydf <- data.frame(matrix(1:6,

Re: [R] Moving 2nd column into 1st column using R

2019-09-09 Thread David Winsemius
On 9/9/19 7:19 PM, smart hendsome via R-help wrote: Hi R-user, I have a problem regarding R.  How can I move my 2nd column into 1st column.  For example I have data as below: mydf <- data.frame(matrix(1:6, ncol = 2))  mydf   X1 X2   1   4   2   5   3   6 I want move my 2nd column become li

[R] Moving 2nd column into 1st column using R

2019-09-09 Thread smart hendsome via R-help
Hi R-user, I have a problem regarding R.  How can I move my 2nd column into 1st column.  For example I have data as below: mydf <- data.frame(matrix(1:6, ncol = 2))  mydf   X1 X2   1   4   2   5   3   6 I want move my 2nd column become like this:   X1    1      2    3    4   5   6 Hope anyone can