0

This problem stems from a previous question. I've come across this solution:

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

Then adding this to the ggplot code with:

scale_x_discrete(breaks = myBreaks, labels = myBreaks) +

Which works. However, when adding median(as.numeric(as.character(x)) to the function, it throws the x-axis haywire. Is there a work around?

Community
  • 1
  • 1
user2726449
  • 607
  • 4
  • 11
  • 23
  • It might speed things up if you were a little more specific than just saying "haywire". – joran Apr 07 '14 at 16:53
  • Well, putting `min`, `median` and `max` in will plot the `min` correctly, the `median` will not be a number that is reasonable (or not plot it at all) which will then cause the `max` to not be correct (either higher or lower than the actual maximum value). Removing `median` from the function will mark `min` and `max` properly, so I'm assuming it has a problem calculating the `median`. – user2726449 Apr 07 '14 at 17:35

0 Answers0