I want to use the ggline of the package ggpubr with 2 aesthetics. The quivalent perfectly works in geom_line but not in ggline. Let's say I have this dataset
data <- data.frame(x = seq(0,1,length.out = 100)) %>%
mutate(a = x^2, b = x^3, c = (x+1)^-1, d = (x + 1)^-2) %>%
pivot_longer(cols = c(a,b,c,d), names_to = 'var',values_to = 'val') %>%
mutate(type = ifelse(var %in% c('a','b'), 'poly','inv'),
order = ifelse(var %in% c('a','c'), 'low','high'))
Now I can use geom_line to get the plot of all.
data %>% ggplot() + geom_line(aes(x = x, y = val, linetype = type, color = order)
No using the same thing ggline
data %>% ggline(x = "x", y = "val", linetype = "type", color = "order")
produces this error
Error: Aesthetics must be either length 1 or the same as the data (400): group
In addition: Warning message:
In if (is_parsable_aes(x)) { :
the condition has length > 1 and only the first element will be used
It seems to me that
ggpubr
doesn't appreciate two different aesthetics onlinetype
andcolor
. It will run with a single variable solution.