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