rank <- as.numeric(rank)
rank[is.na(rank)] <- 0
scale_y_reverse(breaks = 0:28)
that's now the result i have but i want it to become 'new' 0 1 2 3 ... as shown:
it has a few 'new' to the rank. therefore I changed it to be numeric format and then the 'new' become NA. however I want to show it then I make it NA to be 0. but now I want the 0 in the plot to become a 'new' word.
CodePudding user response:
You can use the labels
argument to replace()
the first value:
library(ggplot2)
ggplot()
aes(y = 0:10)
scale_y_reverse(breaks = 0:10, labels = ~ replace(.x, 1, "New"))