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

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.