Using refuge

Refuge Restrooms “is a web application that seeks to provide safe restroom access for transgender, intersex, and gender nonconforming individuals.” The web application includes a public API, which this package allows access to. The API does not require users to sign up or use a key. For further details on the API or the organisation behind it, see the API docs, or the Refuge Restrooms homepage. refuge provides access to the Refuge Restrooms API in R.

Refuge Restrooms uses all user supplied data, which can be messy, and result in inconsistent coverage. It is nonetheless still useful. The example below shows how to convert US state names to the full name, including correcting a couple spelling mistakes, lowercased, and create a map showing the number of unisex, Americans with Disability Act (ADA) accessible restrooms in each state.

library(refuge)
library(ggplot2)
library(usmap)
library(dplyr, warn.conflicts = FALSE)
library(magrittr)
library(viridis)
#> Loading required package: viridisLite
library(stringi)

all <- rfg_all_restrooms(accessible = TRUE, unisex = TRUE, 
                         verbose = TRUE, tidy = TRUE)
#> Retrieving page 1 of 185
#> Retrieving page 2 of 185
#> Retrieving page 3 of 185
#> Retrieving page 4 of 185
#> Retrieving page 5 of 185
#> Retrieving page 6 of 185
#> Retrieving page 7 of 185
#> Retrieving page 8 of 185
#> Retrieving page 9 of 185
#> Retrieving page 10 of 185
#> Retrieving page 11 of 185
#> Retrieving page 12 of 185
#> Retrieving page 13 of 185
#> Retrieving page 14 of 185
#> Retrieving page 15 of 185
#> Retrieving page 16 of 185
#> Retrieving page 17 of 185
#> Retrieving page 18 of 185
#> Retrieving page 19 of 185
#> Retrieving page 20 of 185
#> Retrieving page 21 of 185
#> Retrieving page 22 of 185
#> Retrieving page 23 of 185
#> Retrieving page 24 of 185
#> Retrieving page 25 of 185
#> Retrieving page 26 of 185
#> Retrieving page 27 of 185
#> Retrieving page 28 of 185
#> Retrieving page 29 of 185
#> Retrieving page 30 of 185
#> Retrieving page 31 of 185
#> Retrieving page 32 of 185
#> Retrieving page 33 of 185
#> Retrieving page 34 of 185
#> Retrieving page 35 of 185
#> Retrieving page 36 of 185
#> Retrieving page 37 of 185
#> Retrieving page 38 of 185
#> Retrieving page 39 of 185
#> Retrieving page 40 of 185
#> Retrieving page 41 of 185
#> Retrieving page 42 of 185
#> Retrieving page 43 of 185
#> Retrieving page 44 of 185
#> Retrieving page 45 of 185
#> Retrieving page 46 of 185
#> Retrieving page 47 of 185
#> Retrieving page 48 of 185
#> Retrieving page 49 of 185
#> Retrieving page 50 of 185
#> Retrieving page 51 of 185
#> Retrieving page 52 of 185
#> Retrieving page 53 of 185
#> Retrieving page 54 of 185
#> Retrieving page 55 of 185
#> Retrieving page 56 of 185
#> Retrieving page 57 of 185
#> Retrieving page 58 of 185
#> Retrieving page 59 of 185
#> Retrieving page 60 of 185
#> Retrieving page 61 of 185
#> Retrieving page 62 of 185
#> Retrieving page 63 of 185
#> Retrieving page 64 of 185
#> Retrieving page 65 of 185
#> Retrieving page 66 of 185
#> Retrieving page 67 of 185
#> Retrieving page 68 of 185
#> Retrieving page 69 of 185
#> Retrieving page 70 of 185
#> Retrieving page 71 of 185
#> Retrieving page 72 of 185
#> Retrieving page 73 of 185
#> Retrieving page 74 of 185
#> Retrieving page 75 of 185
#> Retrieving page 76 of 185
#> Retrieving page 77 of 185
#> Retrieving page 78 of 185
#> Retrieving page 79 of 185
#> Retrieving page 80 of 185
#> Retrieving page 81 of 185
#> Retrieving page 82 of 185
#> Retrieving page 83 of 185
#> Retrieving page 84 of 185
#> Retrieving page 85 of 185
#> Retrieving page 86 of 185
#> Retrieving page 87 of 185
#> Retrieving page 88 of 185
#> Retrieving page 89 of 185
#> Retrieving page 90 of 185
#> Retrieving page 91 of 185
#> Retrieving page 92 of 185
#> Retrieving page 93 of 185
#> Retrieving page 94 of 185
#> Retrieving page 95 of 185
#> Retrieving page 96 of 185
#> Retrieving page 97 of 185
#> Retrieving page 98 of 185
#> Retrieving page 99 of 185
#> Retrieving page 100 of 185
#> Retrieving page 101 of 185
#> Retrieving page 102 of 185
#> Retrieving page 103 of 185
#> Retrieving page 104 of 185
#> Retrieving page 105 of 185
#> Retrieving page 106 of 185
#> Retrieving page 107 of 185
#> Retrieving page 108 of 185
#> Retrieving page 109 of 185
#> Retrieving page 110 of 185
#> Retrieving page 111 of 185
#> Retrieving page 112 of 185
#> Retrieving page 113 of 185
#> Retrieving page 114 of 185
#> Retrieving page 115 of 185
#> Retrieving page 116 of 185
#> Retrieving page 117 of 185
#> Retrieving page 118 of 185
#> Retrieving page 119 of 185
#> Retrieving page 120 of 185
#> Retrieving page 121 of 185
#> Retrieving page 122 of 185
#> Retrieving page 123 of 185
#> Retrieving page 124 of 185
#> Retrieving page 125 of 185
#> Retrieving page 126 of 185
#> Retrieving page 127 of 185
#> Retrieving page 128 of 185
#> Retrieving page 129 of 185
#> Retrieving page 130 of 185
#> Retrieving page 131 of 185
#> Retrieving page 132 of 185
#> Retrieving page 133 of 185
#> Retrieving page 134 of 185
#> Retrieving page 135 of 185
#> Retrieving page 136 of 185
#> Retrieving page 137 of 185
#> Retrieving page 138 of 185
#> Retrieving page 139 of 185
#> Retrieving page 140 of 185
#> Retrieving page 141 of 185
#> Retrieving page 142 of 185
#> Retrieving page 143 of 185
#> Retrieving page 144 of 185
#> Retrieving page 145 of 185
#> Retrieving page 146 of 185
#> Retrieving page 147 of 185
#> Retrieving page 148 of 185
#> Retrieving page 149 of 185
#> Retrieving page 150 of 185
#> Retrieving page 151 of 185
#> Retrieving page 152 of 185
#> Retrieving page 153 of 185
#> Retrieving page 154 of 185
#> Retrieving page 155 of 185
#> Retrieving page 156 of 185
#> Retrieving page 157 of 185
#> Retrieving page 158 of 185
#> Retrieving page 159 of 185
#> Retrieving page 160 of 185
#> Retrieving page 161 of 185
#> Retrieving page 162 of 185
#> Retrieving page 163 of 185
#> Retrieving page 164 of 185
#> Retrieving page 165 of 185
#> Retrieving page 166 of 185
#> Retrieving page 167 of 185
#> Retrieving page 168 of 185
#> Retrieving page 169 of 185
#> Retrieving page 170 of 185
#> Retrieving page 171 of 185
#> Retrieving page 172 of 185
#> Retrieving page 173 of 185
#> Retrieving page 174 of 185
#> Retrieving page 175 of 185
#> Retrieving page 176 of 185
#> Retrieving page 177 of 185
#> Retrieving page 178 of 185
#> Retrieving page 179 of 185
#> Retrieving page 180 of 185
#> Retrieving page 181 of 185
#> Retrieving page 182 of 185
#> Retrieving page 183 of 185
#> Retrieving page 184 of 185
#> Retrieving page 185 of 185

all <- all %>% filter(country == "US")

all$state <-  tolower(trimws(all$state))

all$state <- stri_replace_all_fixed(all$state, c("minnestoa", "californa"), 
                                    c("minnesota", "california"),
                                    vectorize_all = FALSE)

all$state <- case_when(all$state %in% tolower(state.name) ~ all$state,
                     all$state %in% c("washington dc", 
                                      "washington, district of columbia",
                                      "columbia", "DC",
                                      "washington district of columbia") ~
                       "District of Columbia", 
                     TRUE ~ tolower(state.name)[match(all$state, tolower(state.abb))])

all <- all %>% filter(!is.na(state)) %>%
  group_by(state) %>% 
  summarise(n_toilets=n())

p_toilets <- plot_usmap(data = all, values = "n_toilets") + 
  scale_fill_viridis(name = "Number of\nRestrooms", label = scales::comma) +
  scale_x_continuous(breaks = NULL) + 
  scale_y_continuous(breaks = NULL) +
  labs(x = "", y = "")

p_toilets

All functions in refuge include parameters to limit queries to accessible and/or unisex restrooms.