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

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.