I have an example dataset:
test <- data.frame(x = c("BG10", "C1456", "DXT6"), y = c("293S", "124F", "124F"))
x y
1 BG10 293S
2 C1456 124F
3 DXT6 124F
where I am ultimately trying to combine columns x
and y
, and then label the new column such that values in x
are on top of y
for plotting purposes:
test %>% mutate(label = paste(x, y, sep = " "), labels = factor(label, labels = bquote(atop(.(x), .(y)))))
the above will give an error.
I thought of creating a vector of expressions:
test %>% split(.$x) %>% map(~ bquote(atop(.(.$x), .(.$y)))) %>% unlist(use.names = FALSE)
[[1]]
atop("BG10", "293S")
[[2]]
atop("C1456", "124F")
[[3]]
atop("DXT6", "124F")
But it would remove the expressions whenever I tried converting the list to a vector. Are there any suggestions on how to go about this? Thanks in advance!