How to swap serial number column with first column of data?

It works with your sample data, please try to provide a proper reprex showing your issue.

squads <- data.frame(
   stringsAsFactors = FALSE,
                 ss = c("Rus","Von","Made","Rido",
                        "P-3","Vry","COR","CO0RU","Cant","AC99","Atlic",
                        "Purpy"),
           Yellow_A = c(6, 0, 6, 1.5, 12, 13, 2, 1.5, 2, 11, 2.5, 0),
           Purple_A = c(0, 1.5, 0, 0, 0, 0, 0, 0, 0, 0, 0, 7),
         Dullness_A = c(9, 9, 12, 11.5, 9.5, 9, 12, 11, 12, 11, 11, 11),
       Smoothness_A = c(4, 8, 11, 1.5, 9, 12, 12.5, 12, 12, 9, 12, 11),
           Gritty_A = c(2, 0, 0, 1.5, 2, 0, 0, 0, 0, 2, 0, 1.5),
  SweetAromatics_AR = c(1.5, 0, 0, 0, 0, 2, 0, 0, 0, 1.5, 0, 0),
     MustyEarthy_AR = c(3.5, 4, 4, 0, 0, 0, 0, 0, 2.5, 0, 0, 3.5)
)

rownames(squads) <- squads$ss
squads[,-1]
#>       Yellow_A Purple_A Dullness_A Smoothness_A Gritty_A SweetAromatics_AR
#> Rus        6.0      0.0        9.0          4.0      2.0               1.5
#> Von        0.0      1.5        9.0          8.0      0.0               0.0
#> Made       6.0      0.0       12.0         11.0      0.0               0.0
#> Rido       1.5      0.0       11.5          1.5      1.5               0.0
#> P-3       12.0      0.0        9.5          9.0      2.0               0.0
#> Vry       13.0      0.0        9.0         12.0      0.0               2.0
#> COR        2.0      0.0       12.0         12.5      0.0               0.0
#> CO0RU      1.5      0.0       11.0         12.0      0.0               0.0
#> Cant       2.0      0.0       12.0         12.0      0.0               0.0
#> AC99      11.0      0.0       11.0          9.0      2.0               1.5
#> Atlic      2.5      0.0       11.0         12.0      0.0               0.0
#> Purpy      0.0      7.0       11.0         11.0      1.5               0.0
#>       MustyEarthy_AR
#> Rus              3.5
#> Von              4.0
#> Made             4.0
#> Rido             0.0
#> P-3              0.0
#> Vry              0.0
#> COR              0.0
#> CO0RU            0.0
#> Cant             2.5
#> AC99             0.0
#> Atlic            0.0
#> Purpy            3.5

Created on 2020-10-12 by the reprex package (v0.3.0)

1 Like