转换因子变量时,myBreaks函数不像中位数(x)

时间:2014-04-07 11:17:31

标签: r ggplot2

此问题源于之前的question。我遇到了solution

myBreaks <- function(x){
breaks <- c(min(as.numeric(as.character(x))),max(as.numeric(as.character(x))))
names(breaks) <- attr(breaks,"labels")
breaks
}

然后将其添加到ggplot代码中:

scale_x_discrete(breaks = myBreaks, labels = myBreaks) +

哪个有效。但是,在向函数添加median(as.numeric(as.character(x))时,会抛出x轴乱序。有工作吗?

0 个答案:

没有答案