鉴于数据:
df <- structure(list(cola = structure(c(5L, 9L, 6L, 2L, 7L, 10L, 3L,
8L, 1L, 4L), .Label = c("a", "b", "d", "g", "q", "r", "t", "w",
"x", "z"), class = "factor"), colb = c(156L, 8L, 6L, 100L, 49L,
31L, 189L, 77L, 154L, 171L), colc = c(0.207140279468149, 0.51990159181878,
0.402017514919862, 0.382948065642267, 0.488511856179684, 0.263168515404686,
0.38591041485779, 0.774066215148196, 0.763264901703224, 0.474355421960354
), cold = structure(c(1L, 2L, 1L, 2L, 1L, 2L, 1L, 2L, 1L, 2L), .Label = c("a",
"b"), class = "factor")), class = "data.frame", row.names = c(NA, …Run Code Online (Sandbox Code Playgroud)