Reordering columns in a large dataframe

前端 未结 8 759
感动是毒
感动是毒 2020-12-12 21:25

Using the following example dataframe:

a <-  c(1:5)
b <- c(\"Cat\", \"Dog\", \"Rabbit\", \"Cat\", \"Dog\")
c <- c(\"Dog\", \"Rabbit\", \"Cat\", \"Do         


        
8条回答
  •  暗喜
    暗喜 (楼主)
    2020-12-12 22:23

    The package dplyr and the function dplyr::relocate, a new verb introduced in dplyr 1.0.0, does exactly what you are looking for.

    df %>% dplyr::relocate(b, c, .after = f)

提交回复
热议问题