问题描述
我想将ggpubr软件包的ggline用于2种美学。等效项完全可以在geom_line中工作,但不能在ggline中工作。假设我有这个数据集
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'))
现在,我可以使用geom_line来获取所有图。
data %>% ggplot() + geom_line(aes(x = x,y = val,linetype = type,color = order)
不使用同一行ggline
data %>% ggline(x = "x",y = "val",linetype = "type",color = "order")
产生此错误
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
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)