我正在寻找一种更简单的方法,为两列中的字符串值组合分配唯一值,其中:
以下是一个解决方案的最小示例如果 colA和colB,其中数字:
set.seed(3)
a <- sample(1:5, 20, replace = T)
b <- sample(1:5, 20, replace = T)
df<- data.frame(a, b)
library(dplyr)
df<- df %>%
filter(a!=b) %>%
mutate(abCombination = a*b) %>%
arrange(abCombination)
df$abFactor <- factor(df$abCombination, labels = c("combination 1", "combination 2",
"combination 3", "combination 4",
"combination 5", "combination 6",
"combination 7"))
我觉得这是一件容易的事,但无法想到:
答案 0 :(得分:3)
假设我们正在寻找适用于then finally, bash setup_p2.sh
的更通用的方法,一种选择是使用numeric/non-numeric
到pmin/pmax
元素然后执行{{1} }
paste