By default, a character vector will be sort in alphabetical order. You can use factor type to help you order a character vector. The order of the factor depends of its levels. You'll need to precise the order at the creation of the factor or after by reordering the factor.
In your case, I use forcats::fct_relevel from tidyverse to reorder the factor's levels so that arrange sort in the desired order.
data('crime', package = "ggmap")
library(tidyverse)
crime <- as_tibble(crime)
# By default it is alphetical order for factor and character
crime %>%
distinct(offense) %>%
arrange(offense)
#> # A tibble: 7 x 1
#> offense
#> <fctr>
#> 1 aggravated assault
#> 2 auto theft
#> 3 burglary
#> 4 murder
#> 5 rape
#> 6 robbery
#> 7 theft
# You need to reorder levels in factor
crime %>%
distinct(offense) %>%
mutate(offense = fct_relevel(offense, c("theft", "auto theft", "robbery", "burglary", "aggravated assault", "rape", "murder"))) %>%
arrange(offense)
#> # A tibble: 7 x 1
#> offense
#> <fctr>
#> 1 theft
#> 2 auto theft
#> 3 robbery
#> 4 burglary
#> 5 aggravated assault
#> 6 rape
#> 7 murder
Created on 2017-12-03 by the reprex package (v0.1.1.9000).
To know more about forcats and how to play with factos, you can go to