R 如何使用;缩放“U x”U反转();因素

R 如何使用;缩放“U x”U反转();因素,r,ggplot2,R,Ggplot2,我正在尝试使用缩放x\u反转()来更改轴的顺序。我在我的情节“AR-2010”、“AR2011”等的顶部写下 但是当我使用scale\u x\u reverse()时,我得到了以下错误 -x中出错:一元运算符的参数无效 这是我的密码 ggplot()+ geom_bar(data=data_iso[order(data_iso$sex,decreasing = T),], aes(x=yeariso,y=ratemort,fill=iso2,group=sex,alp

我正在尝试使用
缩放x\u反转()
来更改轴的顺序。我在我的情节“AR-2010”、“AR2011”等的顶部写下

但是当我使用scale\u x\u reverse()时,我得到了以下错误

-x中出错:一元运算符的参数无效

这是我的密码

ggplot()+ 
  geom_bar(data=data_iso[order(data_iso$sex,decreasing = T),],
           aes(x=yeariso,y=ratemort,fill=iso2,group=sex,alpha=sex,show.legend=F),
           color="transparent",stat="identity")+
  theme_bw()+
  scale_alpha_manual(values=c(0.4, 1)) +
  theme(legend.position="none")+
  labs(color = "Country",x="")+
  ylab(expression(Mortality~Rate~x~10^{5}))+
  scale_fill_manual("",
                    values=c("turquoise","green4","#FFDB6D","chocolate2","brown2",
                             "royalblue","mediumorchid1","pink","lightsalmon","firebrick4"))+
  geom_flag(data=df3,
            aes(x = a, y = b, country = c('ar', 'br', 'cl','co','cr','gt','mx','pe')), 
            size = 15)+
  scale_y_continuous(breaks = c(0,1e+5, 2e+5,3e+5), labels = c("0", "1", "2","3"), 
                     limits=c(14500, 315000), oob = rescale_none)+
  coord_flip()+
  scale_x_reverse()
没有
scale\u x\u reverse()
我得到了下图


缩放x\U反转
适用于连续变量。您应该重新排列变量的因子级别,以反转离散的标度。可能重复的
scale\u x\u reverse
用于连续变量。您应该重新排列变量的因子级别,以反转离散的比例。可能重复