Open vielkahoy opened 2 years ago
## Use the script below to generate a reproducible example ## using the reprex package. Use datapasta::dpasta() to create ## `urban` in the script rather than relying on the source ## CSV file. Once you generate it, post it on ## https://github.com/uc-cfss/reproducible-examples-and-git/issues/1 library(tidyverse) library(here) #> here() starts at /tmp/RtmpmeU4MO/reprex-2104aabfa734-bonny-fox # import data file urban <- tibble::tribble( ~state, ~urbanindex, "Alabama", 9.605935, "Alaska", 8.735964, "American Samoa", 11.08593, "Arizona", 11.29971, "Arkansas", 9.259444, "California", 12.19028, "Colorado", 11.15445, "Connecticut", 11.40968, "Delaware", 11.00999, "District of Columbia", 13.44057, "Florida", 11.46484, "Georgia", 10.55233, "Guam", 11.08593, "Hawaii", 11.08621, "Idaho", 9.593634, "Illinois", 11.62372, "Indiana", 10.4105, "Iowa", 9.593525, "Kansas", 10.12044, "Kentucky", 9.789536, "Louisiana", 10.17518, "Maine", 9.037091, "Maryland", 11.71105, "Massachusetts", 11.83973, "Michigan", 10.80559, "Minnesota", 10.45684, "Mississippi", 8.910859, "Missouri", 10.20212, "Montana", 8.470226, "Nebraska", 10.19912, "Nevada", 11.76972, "New Hampshire", 9.917139, "New Jersey", 12.23565, "New Mexico", 9.896993, "New York", 12.55857, "North Carolina", 10.32481, "North Dakota", 9.054678, "Northern Marianas", 11.08593, "Ohio", 10.87687, "Oklahoma", 9.93928, "Oregon", 10.71233, "Pennsylvania", 11.14623, "Puerto Rico", 11.57168, "Rhode Island", 11.72124, "South Carolina", 10.11142, "South Dakota", 8.728642, "Tennessee", 10.19729, "Texas", 11.17488, "Utah", 10.96281, "Vermont", 8.843222, "Virgin Islands", 11.08593, "Virginia", 10.90625, "Washington", 11.11933, "West Virginia", 9.111112, "Wisconsin", 10.19131, "Wyoming", 8.256294 ) # how do I reorder the bars from largest to smallest? ggplot(data = urban, mapping = aes(x = state, y = urbanindex)) + geom_col() + coord_flip()
Created on 2022-07-05 by the reprex package (v2.0.1)
Created on 2022-07-05 by the reprex package (v2.0.1)