1
我有一個因素變量的2列這樣的數據幀:計數組合因素和它們的逆同時
V1 <- c("A","B","C","Y","D","E","F","U","G","H","I","J","R")
V2 <- c("Z","Y","W","B","V","U","T","E","S","R","Q","P","H")
df <- cbind(V1,V2)
df
V1 V2
[1,] "A" "Z"
[2,] "B" "Y"
[3,] "C" "W"
[4,] "Y" "B"
[5,] "D" "V"
[6,] "E" "U"
[7,] "F" "T"
[8,] "U" "E"
[9,] "G" "S"
[10,] "H" "R"
[11,] "I" "Q"
[12,] "J" "P"
[13,] "R" "H"
現在我woudl喜歡來算,使用的功能,所有的情況下,V1的組合和V2等於組合V2和V1並返回它們,例如用於DF這個計數將等於3,這樣的:
y <-combinations_inver(df[,1],df[,2])
y$Combinations
"B""Y"= "Y""B"
"E""U"= "U""E"
"H""R"= "R""H"
y$Count
[1] 3 #because there are three ocurrences (see $Combinations)