Select the last n columns of data frame in R

前端 未结 7 1010
礼貌的吻别
礼貌的吻别 2021-01-04 04:42

Is there a way to systematically select the last columns of a data frame? I would like to be able to move the last columns to be the first columns, but maintain the order of

7条回答
  •  醉梦人生
    2021-01-04 04:47

    I know this topic is a little dead, but wanted to chime in with a simple dplyr solution:

    library(dplyr)
    
    mydata <- mydata %>%
      select(A, B, everything())
    

    Hopefully that helps out any future visitors to this question.

提交回复
热议问题