I have a big list, but micro example would be like the following:
A <- c("A", "a", "A", "a", "A")
B <- c("A", "A", "a", "a", "a")
C <- c(1, 2, 3, 1, 4)
mylist <- list(A=A, B=B, C= C)
expected output is merge A with B so that each component will look like AB
AA, aA, Aa, aa, Aa
better should be sorted, upper case is always first
AA, Aa, Aa, aa, Aa
Thus new list or matrix should have two columns or rows:
AA, Aa, Aa, aa, Aa
1, 2, 3, 1, 4
Now I want calculate average of C based on class – “AA”, “Aa”, and “aa”
Looks simple but I could not figure out easily.
1 Answer