具有这样一个数据框,该列的列数比执行table()所需的数更多
"aabbfghj" (remove pairs) -> "fghj" (length >0) -> return length-1 = 3 correct
"aabbcc" -> "" (!length >0) -> return length = 0 correct
"aaabb" -> "" -> 0 correct
"aaabbb" -> "" -> 0 correct
"aaabbbccdef" -> "def" -> 2 correct
"aaaaab" -> "b" -> 0 correct
"aabbc" -> "c" -> 0 correct
"aaabbc" -> "c" -> 0 incorrect (should be 1)
我想将所有列都保留在数据框中,这里是预期的输出:
data <- data.frame(id= c(1,2,3), year = c(2018,2018,2019), samples = c("species1","species2","species1"), sample = c("panda","tiger","tiger"))
怎么做呢?