[R] Moving 2nd column into 1st column using R
    Martin Møller Skarbiniks Pedersen 
    tr@xp|@yer @end|ng |rom gm@||@com
       
    Wed Sep 11 14:36:15 CEST 2019
    
    
  
On Tue, 10 Sep 2019 at 04:20, smart hendsome via R-help <
r-help using 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   6
> I want move my 2nd column become like this:
>   X1    1      2    3    4   5   6
> Hope anyone can help me. Many thanks.
I am not sure I understand your problem, but try:
mydf <- data.frame(matrix(1:6, ncol = 2, byrow = TRUE))
Regards
Martin
	[[alternative HTML version deleted]]
    
    
More information about the R-help
mailing list