X <- round(quantile(Retaildata$monthly_salary.x,c(.90,.92,.94,.96,.98,1)),0)
Y <- c('P90','P92','P94','P96','P98','P100')
library(ggplot2)
qplot(x=Y,y=X,label=X,geom = c('text','point'), hjust = -.25)
为什么P100
显示在最左侧?
我怎么把它带到最后,即向右?
答案 0 :(得分:1)
试试这个:
set.seed(1)
X <- round(quantile(abs(rnorm(1000))*12500,c(.90,.92,.94,.96,.98,1)),0)
Y <- c('P90','P92','P94','P96','P98','P100')
# 'mixedsort' orders character strings containing embedded numbers so that
# the numbers are numerically sorted rather than sorted by character value
library(gtools)
Y <- factor(Y, levels=mixedsort(Y))
library(ggplot2)
qplot(x=Y,y=X,label=X,geom = c('text','point'), hjust = -.25)