1. data <- tibble(
    2. 商品名称 = c("飞机","坦克","火车","汽车","电脑","微波炉","电冰箱"),
    3. "20201" = c(1148180,936847.03,756678.94,661634.81,517844.34,515342.05,402535.4),
    4. "20202" = c(724438,394463.6,299565.12,218171.05,77576.46,238128.77,84461.59),
    5. "20203" = c(806344,599225.03,348673.68,287861.24,398617.05,294147.36,122243.58),
    6. "20204" = c(1148928,985200.86,612672.88,576676.61,941509.14,520207.97,351694.72),
    7. "20205" = c(1267112,509108.92,529845.63,831958.88,877673.16,362104.54,371722.34)
    8. )
    9. data %>% mutate(across(-1,~rank(.x),.names = "{.col}_rank)"))
    10. # A tibble: 7 x 11
    11. # 商品名称 `20201` `20202` `20203` `20204` `20205` `20201_rank)` `20202_rank)` `20203_rank)` `20204_rank)`
    12. # <chr> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl>
    13. # 1 飞机 1148180 724438 806344 1148928 1267112 7 7 7 7
    14. # 2 坦克 936847. 394464. 599225. 985201. 509109. 6 6 6 6
    15. # 3 火车 756679. 299565. 348674. 612673. 529846. 5 5 4 4
    16. # 4 汽车 661635. 218171. 287861. 576677. 831959. 4 3 2 3
    17. # 5 电脑 517844. 77576. 398617. 941509. 877673. 3 1 5 5
    18. # 6 微波炉 515342. 238129. 294147. 520208. 362105. 2 4 3 2
    19. # 7 电冰箱 402535. 84462. 122244. 351695. 371722. 1 2 1 1
    20. # ... with 1 more variable: `20205_rank)` <dbl>
    21. >