在 SO 上找不到确切的解决方案,无论如何都希望使用 tidyverse 包的最简洁版本。希望除第一列之外的所有列都是整数,并在现实生活场景中满足更多列
df <- structure(list(col_1 = structure(1:3, .Label = c("a", "b", "c"
), class = "factor"), col_2 = structure(c(1L, 3L, 2L), .Label = c("1,234",
"23", "4,567"), class = "factor"), col_3 = structure(1:3, .Label = c("1234",
"46", "6,789"), class = "factor")), .Names = c("col_1", "col_2",
"col_3"), row.names = c(NA, -3L), class = "data.frame")
TIA