Homework 2

What is the data being evaluated and what questions are being asked

The tables will be pulled from the indicators page (https://www.who.int/data/gho/data/indicators), specifically for the assistve technology (AT) indicator, on the WHO website.

Research Questions

  • What is the prevalence for need and use assistive technologies (ATs) across the data?

  • What is the prevalence for need and use of vision related assistive technologies (ATs) within a specific parent location (Europe)? What about across the different countries within Europe?

  • What is the prevalence for need and use of cognitive related assistive technologies (ATs) within a specific parent location (Europe)? What about across the different countries within Europe?

  • How does the need and use of ATs compare across parent locations? Are they correlated with each other (e.g. if the need increases, does use increase, decrease or neither)

  • What are the most common types of AT education in each country?

Pull in Data from World Health Organization (WHO)

Pull in Prevalence of AT use Data

prevATUse <- read_csv("Final Project/Prev_Use_AT.csv")
## Rows: 1430 Columns: 34
## ── Column specification ────────────────────────────────────────────────────────
## Delimiter: ","
## chr  (15): IndicatorCode, Indicator, ValueType, ParentLocationCode, ParentLo...
## dbl   (3): Period, FactValueNumeric, FactValueTranslationID
## lgl  (15): IsLatestYear, Dim2 type, Dim2, Dim2ValueCode, Dim3 type, Dim3, Di...
## dttm  (1): DateModified
## 
## ℹ Use `spec()` to retrieve the full column specification for this data.
## ℹ Specify the column types or set `show_col_types = FALSE` to quiet this message.
head(prevATUse)
## # A tibble: 6 × 34
##   IndicatorCode            Indicator ValueType ParentLocationCode ParentLocation
##   <chr>                    <chr>     <chr>     <chr>              <chr>         
## 1 ASSISTIVETECH_USEPREVAL… Prevalen… numeric   EUR                Europe        
## 2 ASSISTIVETECH_USEPREVAL… Prevalen… numeric   EUR                Europe        
## 3 ASSISTIVETECH_USEPREVAL… Prevalen… numeric   EUR                Europe        
## 4 ASSISTIVETECH_USEPREVAL… Prevalen… numeric   EUR                Europe        
## 5 ASSISTIVETECH_USEPREVAL… Prevalen… numeric   EUR                Europe        
## 6 ASSISTIVETECH_USEPREVAL… Prevalen… numeric   EUR                Europe        
## # ℹ 29 more variables: `Location type` <chr>, SpatialDimValueCode <chr>,
## #   Location <chr>, `Period type` <chr>, Period <dbl>, IsLatestYear <lgl>,
## #   `Dim1 type` <chr>, Dim1 <chr>, Dim1ValueCode <chr>, `Dim2 type` <lgl>,
## #   Dim2 <lgl>, Dim2ValueCode <lgl>, `Dim3 type` <lgl>, Dim3 <lgl>,
## #   Dim3ValueCode <lgl>, DataSourceDimValueCode <lgl>, DataSource <lgl>,
## #   FactValueNumericPrefix <lgl>, FactValueNumeric <dbl>, FactValueUoM <lgl>,
## #   FactValueNumericLowPrefix <lgl>, FactValueNumericLow <lgl>, …

Pull in Prevalence of AT need Data

prevATNeed <- read_csv("Final Project/Prev_Need_AT.csv")
## Rows: 1435 Columns: 34
## ── Column specification ────────────────────────────────────────────────────────
## Delimiter: ","
## chr  (15): IndicatorCode, Indicator, ValueType, ParentLocationCode, ParentLo...
## dbl   (3): Period, FactValueNumeric, FactValueTranslationID
## lgl  (15): IsLatestYear, Dim2 type, Dim2, Dim2ValueCode, Dim3 type, Dim3, Di...
## dttm  (1): DateModified
## 
## ℹ Use `spec()` to retrieve the full column specification for this data.
## ℹ Specify the column types or set `show_col_types = FALSE` to quiet this message.
head(prevATNeed)
## # A tibble: 6 × 34
##   IndicatorCode           Indicator  ValueType ParentLocationCode ParentLocation
##   <chr>                   <chr>      <chr>     <chr>              <chr>         
## 1 ASSISTIVETECH_TOTALNEED Prevalenc… numeric   AFR                Africa        
## 2 ASSISTIVETECH_TOTALNEED Prevalenc… numeric   AFR                Africa        
## 3 ASSISTIVETECH_TOTALNEED Prevalenc… numeric   AFR                Africa        
## 4 ASSISTIVETECH_TOTALNEED Prevalenc… numeric   AFR                Africa        
## 5 ASSISTIVETECH_TOTALNEED Prevalenc… numeric   AFR                Africa        
## 6 ASSISTIVETECH_TOTALNEED Prevalenc… numeric   AFR                Africa        
## # ℹ 29 more variables: `Location type` <chr>, SpatialDimValueCode <chr>,
## #   Location <chr>, `Period type` <chr>, Period <dbl>, IsLatestYear <lgl>,
## #   `Dim1 type` <chr>, Dim1 <chr>, Dim1ValueCode <chr>, `Dim2 type` <lgl>,
## #   Dim2 <lgl>, Dim2ValueCode <lgl>, `Dim3 type` <lgl>, Dim3 <lgl>,
## #   Dim3ValueCode <lgl>, DataSourceDimValueCode <lgl>, DataSource <lgl>,
## #   FactValueNumericPrefix <lgl>, FactValueNumeric <dbl>, FactValueUoM <lgl>,
## #   FactValueNumericLowPrefix <lgl>, FactValueNumericLow <lgl>, …

Pull in Educational resources for AT Data

eduAT <- read_csv("Final Project/Ava_Edu_AT.csv")
## Rows: 490 Columns: 34
## ── Column specification ────────────────────────────────────────────────────────
## Delimiter: ","
## chr  (14): IndicatorCode, Indicator, ValueType, ParentLocationCode, ParentLo...
## dbl   (2): Period, FactValueTranslationID
## lgl  (17): IsLatestYear, Dim2 type, Dim2, Dim2ValueCode, Dim3 type, Dim3, Di...
## dttm  (1): DateModified
## 
## ℹ Use `spec()` to retrieve the full column specification for this data.
## ℹ Specify the column types or set `show_col_types = FALSE` to quiet this message.
head(eduAT)
## # A tibble: 6 × 34
##   IndicatorCode     Indicator        ValueType ParentLocationCode ParentLocation
##   <chr>             <chr>            <chr>     <chr>              <chr>         
## 1 ASSISTIVETECH_Q07 Availability of… text      EMR                Eastern Medit…
## 2 ASSISTIVETECH_Q07 Availability of… text      EMR                Eastern Medit…
## 3 ASSISTIVETECH_Q07 Availability of… text      EMR                Eastern Medit…
## 4 ASSISTIVETECH_Q07 Availability of… text      EMR                Eastern Medit…
## 5 ASSISTIVETECH_Q07 Availability of… text      EMR                Eastern Medit…
## 6 ASSISTIVETECH_Q07 Availability of… text      EMR                Eastern Medit…
## # ℹ 29 more variables: `Location type` <chr>, SpatialDimValueCode <chr>,
## #   Location <chr>, `Period type` <chr>, Period <dbl>, IsLatestYear <lgl>,
## #   `Dim1 type` <chr>, Dim1 <chr>, Dim1ValueCode <chr>, `Dim2 type` <lgl>,
## #   Dim2 <lgl>, Dim2ValueCode <lgl>, `Dim3 type` <lgl>, Dim3 <lgl>,
## #   Dim3ValueCode <lgl>, DataSourceDimValueCode <lgl>, DataSource <lgl>,
## #   FactValueNumericPrefix <lgl>, FactValueNumeric <lgl>, FactValueUoM <lgl>,
## #   FactValueNumericLowPrefix <lgl>, FactValueNumericLow <lgl>, …

Clean up the the three data tables before joining them

I checked different columns using distinct function in the console to remove any columns that did not contain any data. I also checked to see if columns have repetitive data (e.g. Dim 1 Type has the same information found in Dim1 and Dim1ValueCode).

I will remove all these columns from all the data sets with the intention to join them when we learn how to do that next week.

#remove `IndicatorCode`, `ValueType`, `ParentLocationCode`, `Location type`, `SpatialDimValueCode`, `Period type`, `IsLatestYear`, `Dim1 type`, `Dim2 type`, `Dim3 type`. `DataSource`, `FactValueNumericPrefix`, `FactValueUoM`, `FactValueNumericLowPrefix`, `FactValueNumericHigh`, `Language` from all the data sets 

prevATUseClean <- prevATUse %>% 
  select(-`IndicatorCode`, -`ValueType`, -`ParentLocationCode`, 
         -`Location type`, -`SpatialDimValueCode`, -`Period type`, 
         -`IsLatestYear`, -`Dim1 type`, -`Dim2 type`, -`Dim3 type`,
         -`DataSource`, -`FactValueNumericPrefix`, -`FactValueUoM`, 
         -`FactValueNumericLowPrefix`, -`FactValueNumericHigh`, -`Language`)

prevATNeedClean <- prevATNeed %>% 
  select(-`IndicatorCode`, -`ValueType`, -`ParentLocationCode`, 
         -`Location type`, -`SpatialDimValueCode`, -`Period type`, 
         -`IsLatestYear`, -`Dim1 type`, -`Dim2 type`, -`Dim3 type`,
         -`DataSource`, -`FactValueNumericPrefix`, -`FactValueUoM`, 
         -`FactValueNumericLowPrefix`, -`FactValueNumericHigh`, -`Language`)

eduATClean <- eduAT %>% 
  select(-`IndicatorCode`, -`ValueType`, -`ParentLocationCode`, 
         -`Location type`, -`SpatialDimValueCode`, -`Period type`, 
         -`IsLatestYear`, -`Dim1 type`, -`Dim2 type`, -`Dim3 type`,
         -`DataSource`, -`FactValueNumericPrefix`, -`FactValueUoM`, 
         -`FactValueNumericLowPrefix`, -`FactValueNumericHigh`, -`Language`)

Re-class variable as needed

#NEED DATA FRAME: make `Value` numeric rather than categorical as it is the decimal of what the prevalence of each assistive technology is in each country
class(prevATNeedClean$Value)
## [1] "character"
#NEED DATA FRAME: change Value from character to numeric
prevATNeedClean$Value <- as.numeric(gsub("[^0-9.]", "", prevATNeedClean$Value))

#NEED DATA FRAME: Check the data type again
class(prevATNeedClean$Value)
## [1] "numeric"
#USE DATA FRAME: make `Value` numeric rather than categorical as it is the decimal of what the prevalence of each assistive technology is in each country
class(prevATUseClean$Value)
## [1] "character"
#USE DATA FRAME: change Value from character to numeric
prevATUseClean$Value <- as.numeric(gsub("[^0-9.]", "", prevATUseClean$Value))

#USE DATA FRAME: Check the data type again
class(prevATUseClean$Value)
## [1] "numeric"

Shorten names of AT

shortenATLabels <- function(data) {
  shorten <- data %>% 
    mutate(DimUpdated = case_when(
      Dim1 %in% c("Audio-players with DAISY capability") ~ "Audio-players",
      Dim1 %in% c("Grab-bars / Hand rails") ~ "Grab-bars",
      Dim1 %in% c("Braille displays (note takers)") ~ "Braille displays",
      Dim1 %in% c("Braille writing equipment/braillers") ~ "Braille writing", 
      Dim1 %in% c("Closed captioning displays") ~ "CC display",
      Dim1 %in% c("Pressure relief cushions") ~ "Cushions",
      Dim1 %in% c("Deafblind communicators (for seeing/vision)") ~ "Deafblind vision comms.",
      Dim1 %in% c("Gesture to voice technology") ~ "Gesture to voice",
      Dim1 %in% c("Global Positioning System (GPS) locators") ~ "GPS locator",
      Dim1 %in% c("Keyboard and mouse emulation software") ~ "Keyboard/mouse emulation",
      Dim1 %in% c("Orthoses (upper limb)") ~ "Upper orthoses",
      Dim1 %in% c("Personal emergency alarm systems") ~ "Alarm system",
      Dim1 %in% c("Prostheses (lower limb)") ~ "Lower protheses",
      Dim1 %in% c("Prostheses (upper limb)*") ~ "Upper protheses",
      Dim1 %in% c("Ramps, portable") ~ "Portable ramp",
      Dim1 %in% c("Rollators") ~ "Walker",
      Dim1 %in% c("Screen readers") ~ "Screen reader",
      Dim1 %in% c("Simplified mobile phones") ~ "Simplified mobile phones",
      Dim1 %in% c("Smart phones/tablets/PDA (for communication)") ~ "Smart phone for comm",
      Dim1 %in% c("Smart phones/tablets/PDA (for hearing)") ~ "Smart phone for hearing",
      Dim1 %in% c("Smart phones/tablets/PDA (for seeing/vision)") ~ "Smart phone for vision",
      Dim1 %in% c("Therapeutic footwear (diabetic, neuropathic, orthopedic)") ~ "Therapeutic footwear",
      Dim1 %in% c("Travel aids, portable") ~ "Travel aids",
      Dim1 %in% c("Video communication devices") ~ "Video comms",
      Dim1 %in% c("Watches, talking/touching") ~ "Watches",
      Dim1 %in% c("Deafblind communicators (for hearing)") ~ "Deafblind vision hearing",
      Dim1 %in% c("Hearing loops/FM systems") ~ "Hearing loops",
      Dim1 %in% c("Incontinence products, absorbent") ~ "Incontinence Prod",
      Dim1 %in% c("Smart phones/tablets/PDA (for cognition)") ~ "Smart phone for cog.",
      Dim1 %in% c("Standing frames, adjustable") ~ "Standing frames",
      Dim1 %in% c("Time management products") ~ "Time Manag.",
      Dim1 %in% c("Chairs for shower/bath/toilet") ~ "Shower Chairs",
      Dim1 %in% c("Club foot braces") ~ "Foot braces",
      Dim1 %in% c("Communication boards/books/cards") ~ "Comms Boards",
      Dim1 %in% c("Communication software") ~ "Comms software",
      Dim1 %in% c("Magnifiers, digital handheld") ~ "Digital Magnifier",
      Dim1 %in% c("Magnifiers, optical") ~ "Optical magnifier",
      Dim1 %in% c("Orthoses (lower limb)") ~ "Lower Orthoses",
      Dim1 %in% c("Wheelchairs, electrically powered") ~ "Electric wheelchair",
      Dim1 %in% c("Wheelchairs, manual with postural support") ~ "Manual wheelchair",
      Dim1 %in% c("Alarm signalers with light/sound/vibration") ~ "A11y alarm signalers",
      Dim1 %in% c("Orthoses (spinal)") ~ "Spinal Orthoses",
      Dim1 %in% c("walking frames/walkers") ~ "Walker",
      Dim1 %in% c("Manual wheelchairs - push type") ~ "Manual Wheelchair",
      Dim1 %in% c("Manual wheelchairs - basic type for active users") ~ "Manual Wheelchair",
      Dim1 %in% c("Axillary / Elbow crutches") ~ "Crutches",
      Dim1 %in% c("Hearing aids (digital) and batteries") ~ "Hearing Aids",
      Dim1 %in% c("Canes/sticks, tripod and quadripod") ~ "Canes",
      Dim1 %in% c("Spectacles; low-vision, short/long distance/filters etc") ~ "Vision Glasses",
      TRUE ~ as.character(Dim1)
    ))
  return(shorten)
}

Apply shortened names to all three data sets

prevATUseClean1 <- shortenATLabels(prevATUseClean)

prevATNeedClean1 <- shortenATLabels(prevATNeedClean) 

Defining AT to Disability group

During this analysis, I want to have visualizations of the prevalent different types of assistive technology grouped by different accessibility groups. In order to look at all these assistive technologies, I will be grouping them into 6 accessibility/disability categories. I organized it by the accessibility/disability category that I believe it is the most applicable to.

This approach has it limitations. Assistive technology does not ‘belong’ to only one accessibility/disability category as it can be applicable to multiple different disabilities. This is just to give a visual estimation that is visually less overwhelming than seeing 53 individual type of assistive technologies.

Below are how I categorized the assistive technologies.

HEARING

Audio-players

CC display

Gesture to voice

Smart phone for hearing

Deafblind vision hearing

Hearing loops

Hearing Aids

A11y alarm signalers

LOWER BODY MOBILITY

Grab-bars

Cushions

Fall detectors

Lower protheses

Portable ramp

Walker

Therapeutic footwear

Travel aids

tricycles

Standing frames

Shower Chairs

Pressure relief mattresses

Foot braces

Lower Orthoses

Electric wheelchair

Manual wheelchair

Spinal Orthoses

Manual Wheelchair

Crutches

VISION

Braille displays

Braille writing

Screen reader

Smart phone for vision

White canes

Digital Magnifier

Optical magnifier

Canes

Vision Glasses

COGNITION

GPS locator

Alarm system

Pill organizers

Simplified mobile phones

Watches

Incontinence Prod

Smart phone for cog.

Time Manag.

Recorders

UPPER BODY MOBILITY

Keyboard/mouse emulation

Upper orthoses

Upper protheses

SPEECH

Smart phone for comm

Deafblind vision comms.

Video comms

Comms Boards

Comms software

#Create function so all data frames can have a new column added for accessibility category
a11yCatAdded <- function(data) {
  result <- data %>%
    mutate('Accessibility Category' = case_when(
      `DimUpdated` %in% c(
        "Braille displays",  
        "Braille writing", 
        "Screen reader", 
        "Smart phone for vision", 
        "White canes",
        "Digital Magnifier", 
        "Optical magnifier", 
        "Vision Glasses"
      ) ~ "Vision AT",
      `DimUpdated` %in% c(
        "Audio-players",
        "CC display",
        "Gesture to voice",
        "Smart phone for hearing",
        "Deafblind vision hearing",
        "Hearing loops",
        "Hearing Aids",
        "A11y alarm signalers"
      ) ~ "Hearing AT",
      `DimUpdated` %in% c(
        "Grab-bars", 
        "Cushions",
        "Fall detectors",
        "Lower protheses",
        "Portable ramp",
        "Walker",
        "Therapeutic footwear",
        "Travel aids",
        "tricycles",
        "Standing frames",
        "Shower Chairs",
        "Pressure relief mattresses",
        "Foot braces",
        "Lower Orthoses",
        "Electric wheelchair",
        "Manual wheelchair",
        "Spinal Orthoses",
        "Manual Wheelchair",
        "Canes", 
        "Crutches"
      ) ~ "Lower Mobility AT",
      `DimUpdated` %in% c(
        "GPS locator",
        "Alarm system",
        "Pill organizers",
        "Simplified mobile phones",
        "Watches",
        "Incontinence Prod",
        "Smart phone for cog.",
        "Time Manag.",
        "Recorders"
      ) ~ "Cognition AT",
      `DimUpdated` %in% c(
        "Keyboard/mouse emulation",
        "Upper orthoses",
        "Upper protheses"
      ) ~ "Upper Mobility AT",
      `DimUpdated` %in% c(
        "Smart phone for comm",
        "Deafblind vision comms.",
        "Video comms",
        "Comms Boards",
        "Comms software"
      ) ~ "Speech AT",
      TRUE ~ as.character(`DimUpdated`)
    ))
  return(result)
}

# Apply the function to your data frames
prevATUseClean2 <- a11yCatAdded(prevATUseClean1)
prevATNeedClean2 <- a11yCatAdded(prevATNeedClean1)

What countries are included in the different parent areas?

World health organization does not all have the data for all the countries in the world. So the graphs don’t get mis-interperted without being aware of what coutries are included, below is a table of all the countries grouped by their parent location.

#Countries within the use prevalance data frame
countriesPrevATUse <- prevATUseClean2 %>%
  group_by(ParentLocation) %>%
  summarize(
    Locations = toString(unique(Location)),
    LocationCount = n_distinct(Location)
  )

#Countries within the need prevalance data frame. This is the same as the use data frame
countriesPrevATNeed <- prevATNeedClean2 %>%
  group_by(ParentLocation) %>%
  summarize(
    Locations = toString(unique(Location)),
    LocationCount = n_distinct(Location)
  )

# for reference the Americas can actually be broken down into 4 areas (North America, South America, The Caribbean, Central America) Within those four areas there are 35 countries. This who data frame only has 2 countries data. It is important to take the visualations and data with a large grain of salt. It will not be representative of the parent areas. 

#Countries within the education avaliability data frame. This is the same as the use data frame. This is more represenative than the other two data frames
countriesEduAT <- eduATClean %>%
  group_by(ParentLocation) %>%
  summarize(
    Locations = toString(unique(Location)),
    LocationCount = n_distinct(Location)
  )

What is the prevalence for need and use assistive technologies (ATs) across the data?

Visualization of need

#organizing the data by grouping by parent country and accessibility (a11y) category type. The summing up the prevalnce of the categorized AT for each parent location. Since not all the data is avaliable for all types of AT, I have it remove NA values
prevNeedA11yCatParentLocation <- prevATNeedClean2 %>%
  group_by(ParentLocation, `Accessibility Category`) %>% 
  summarise(sumValue = sum(FactValueNumeric, na.rm = TRUE)) %>%
  ungroup() %>% 
  mutate(sumValue = as.integer(sumValue))
## `summarise()` has grouped output by 'ParentLocation'. You can override using
## the `.groups` argument.
#visualing the different parent locations by AT category. Vision has the most need across all the parent countries followed behind with lower mobility AT. Hearing and cognitive AT are very close and switch between 3rd and 4th depending on the parent location
prevNeedA11yCatParentLocation %>% 
  ggplot(aes(x = reorder(`Accessibility Category`, -sumValue), y = sumValue)) +
  geom_bar(stat = "identity", fill = 'black') +
  geom_text(aes(label = sumValue), vjust = -0.5, color = "white", size = 3) +
  theme_dark() +
  theme(axis.text.x = element_text(angle = 45, hjust = 1), plot.title = element_text(hjust = 0.5)) +
  labs(title = "Assistive Tech need prevalence grouped\n by Accessibility category and Parent Location", x = "Assistive Technology Category") +
  scale_y_continuous(name = "Prevalence", labels = scales::percent_format(scale = 1), limits = c(0, 350)) +
  facet_wrap(vars(ParentLocation))

Visualization of Use

prevUseA11yCatParentLocation <- prevATUseClean2 %>%
  group_by(ParentLocation, `Accessibility Category`) %>% 
  summarise(sumValue = sum(FactValueNumeric, na.rm = TRUE)) %>%
  ungroup() %>% 
  mutate(sumValue = as.integer(sumValue))
## `summarise()` has grouped output by 'ParentLocation'. You can override using
## the `.groups` argument.
#visualing the different parent locations by AT category. Use follows the same trend as need prevelance although the look a bit lower. 
prevUseA11yCatParentLocation %>% 
  ggplot(aes(x = reorder(`Accessibility Category`, -sumValue), y = sumValue)) +
  geom_bar(stat = "identity", fill = 'black') +
  geom_text(aes(label = sumValue), vjust = -0.5, color = "white", size = 3) +
  theme_dark() +
  theme(axis.text.x = element_text(angle = 45, hjust = 1), plot.title = element_text(hjust = 0.5)) +
  labs(title = "Assistive Tech use prevalence grouped\n by Accessibility category and Parent Location", x = "Assistive Technology Category") +
  scale_y_continuous(name = "Prevalence", labels = scales::percent_format(scale = 1), limits = c(0, 350)) +
  facet_wrap(vars(ParentLocation))

How does the need and use of ATs compare across parent locations?

Join use and need data

#making a table with only the information I need before I join it together. Also re-labeling the value column to be specific to need values
prevNeedA11yCatParentLocation1 <- prevNeedA11yCatParentLocation %>% 
  rename("Need Value" = sumValue)

#re-labeling the value column to be specific to use values
prevUseA11yCatParentLocation1 <- prevUseA11yCatParentLocation %>% 
  rename("Use Value" = sumValue)

#joining the two simplified data frames
prevNeedVsUseParentLocation <- left_join(
  prevNeedA11yCatParentLocation1,
  prevUseA11yCatParentLocation1,
  by = c("ParentLocation", "Accessibility Category")
)
#pivoting longer to column the values in Need Value and Use values

prevNeedVsUseParentLocationLong <- prevNeedVsUseParentLocation %>% 
  pivot_longer(c(`Need Value`, `Use Value`), names_to = "PrevType", values_to = "Value")

#making the visualization. Although the bars are next to each other, it is hard to read what the difference in need versus use is for each category. 
prevNeedVsUseParentLocationLong %>% 
  group_by(ParentLocation, `Accessibility Category`, PrevType) %>% 
  summarise(sumValue = sum(Value, na.rm = TRUE)) %>%
  ungroup() %>%
  ggplot(aes(x = reorder(`Accessibility Category`, -sumValue), y = sumValue, fill = PrevType)) +
  geom_bar(stat = "identity", position = "dodge", color = "black") +
  geom_text(aes(label = sumValue), position = position_dodge(width = 0.9), vjust = -0.5, color = "black", size = 3) +
  scale_fill_okabeito(name = "Prevalence") +
  theme_minimal() +
  theme(axis.text.x = element_text(angle = 45, hjust = 1), plot.title = element_text(hjust = 0.5)) +
  labs(
    title = "Assistive Tech need and use prevalence grouped by\n Accessibility category and Parent Location",
    x = "Assistive Technology Category",
    y = "Prevalence",
    fill = "PrevType"
  ) +
  scale_y_continuous(labels = scales::percent_format(scale = 1), limits = c(0, 350)) +
  facet_wrap(vars(ParentLocation), scales = "free_x")
## `summarise()` has grouped output by 'ParentLocation', 'Accessibility Category'.
## You can override using the `.groups` argument.

Subtracting need versus use to better see the difference

#subtracting the need versus use
prevNeedVsUseParentLocation1 <- prevNeedVsUseParentLocation %>%
  mutate(`Difference Between Need and Use` = (`Use Value` - `Need Value`))


#plot the difference. If it is a positive number then the use is more than the need (colored green). If it is a negative number then the need is more than use (colored red). There is no country that has more use than reported need. Vision and low mobility have the most difference across the board for all parent countries
prevNeedVsUseParentLocation1 %>% 
  ggplot(aes(
    x = reorder(`Accessibility Category`, `Difference Between Need and Use`),
    y = `Difference Between Need and Use`,
    fill = `Difference Between Need and Use`
  )) +
  geom_bar(stat = "identity", position = "dodge", color = "black") +
  geom_text(
    aes(label = `Difference Between Need and Use`),
    position = position_dodge(width = 0.9),
    vjust = -0.5,
    color = "black",
    size = 3
  ) +
  scale_fill_gradientn(
    name = "Difference Between Need and Use",
    colors = c("red", "green"),
    values = scales::rescale(c(-40, 40)),
    limits = c(-40, 40)
  ) +
  theme_minimal() +
  theme(axis.text.x = element_text(angle = 60, hjust = 1), plot.title = element_text(hjust = 0.5)) +
  labs(
    title = "Assistive Tech need and use prevalence grouped by\n Accessibility category and Parent Location",
    x = "Assistive Technology Category",
    y = "Prevalence",
    fill = "Difference Between Need and Use"
  ) +
  scale_y_continuous(limits = c(-40, 40)) +
  facet_wrap(vars(ParentLocation), scales = "free_x")
## Warning: Removed 1 rows containing missing values (`geom_bar()`).
## Warning: Removed 1 rows containing missing values (`geom_text()`).

By AT

#updating the data frame with specific AT column and removing the a11y category column within the the need prevalence data
prevNeedATParentLocation2 <- prevNeedATParentLocation1 %>% 
  rename("Need Value" = sumValue)


#updating the data frame with specific AT column and removing the a11y category column within the the use prevalence data
prevUsedATParentLocation2 <- prevUseATParentLocation1 %>% 
  rename("Use Value" = sumValue)

#joining the two simplified data frames
prevNeedVsUseATParentLocation <- left_join(
  prevNeedATParentLocation2,
  prevUsedATParentLocation2,
  by = c("ParentLocation", "Location", "DimUpdated")
)

#subtracting the need versus use
prevNeedVsUseATParentLocation1 <- prevNeedVsUseATParentLocation %>%
  mutate(`Difference Between Need and Use` = (`Use Value` - `Need Value`))

print(prevNeedVsUseATParentLocation1)
## # A tibble: 1,378 × 8
##    ParentLocation Location     DimUpdated    Accessibility Catego…¹ `Need Value`
##    <chr>          <chr>        <chr>         <chr>                         <int>
##  1 Africa         Burkina Faso A11y alarm s… Hearing AT                        0
##  2 Africa         Burkina Faso Alarm system  Cognition AT                      0
##  3 Africa         Burkina Faso Audio-players Hearing AT                        0
##  4 Africa         Burkina Faso Braille disp… Vision AT                         0
##  5 Africa         Burkina Faso Braille writ… Vision AT                         0
##  6 Africa         Burkina Faso CC display    Hearing AT                        0
##  7 Africa         Burkina Faso Canes         Lower Mobility AT                 1
##  8 Africa         Burkina Faso Comms Boards  Speech AT                         0
##  9 Africa         Burkina Faso Comms softwa… Speech AT                         0
## 10 Africa         Burkina Faso Crutches      Lower Mobility AT                 1
## # ℹ 1,368 more rows
## # ℹ abbreviated name: ¹​`Accessibility Category.x`
## # ℹ 3 more variables: `Accessibility Category.y` <chr>, `Use Value` <int>,
## #   `Difference Between Need and Use` <int>
# Specific Europe vision difference between need and use. Just like in the other chart, if it is a positive number then the use is more than the need (colored green). If it is a negative number then the need is more than use (colored red). Vision glasses have the highest different with use and need. 
prevNeedVsUseATParentLocation1 %>% 
  filter(`Accessibility Category.x` == "Vision AT", ParentLocation == "Europe") %>%
  group_by(ParentLocation, DimUpdated) %>%
  summarise(`Difference Between Need and Use` = sum(`Difference Between Need and Use`, na.rm = TRUE), .groups = "keep") %>%
  ggplot(aes(
    x = reorder(DimUpdated, `Difference Between Need and Use`),
    y = `Difference Between Need and Use`,
    fill = `Difference Between Need and Use`
  )) +
  geom_bar(stat = "identity", position = "dodge", color = "black") +
  geom_text(
    aes(label = `Difference Between Need and Use`),
    position = position_dodge(width = 0.9),
    vjust = -0.5,
    color = "black",
    size = 3
  ) +
  scale_fill_gradientn(
    name = "Difference Between Need and Use",
    colors = c("red", "green"),
    values = scales::rescale(c(-40, 40)),
    limits = c(-40, 40)
  ) +
  theme_minimal() +
  theme(axis.text.x = element_text(angle = 60, hjust = 1), plot.title = element_text(hjust = 0.5)) +
  labs(
    title = "Assistive Tech need and use prevalence grouped for\n vision AT within Europe",
    x = "Assistive Technology",
    y = "Prevalence",
    fill = "Difference Between Need and Use"
  ) +
  scale_y_continuous(limits = c(-40, 40)) +
  facet_wrap(vars(ParentLocation), scales = "free_x")

What are the most common types of AT education in each country?

#filter out the no information and counting the different values (full, partial or no coverage)
eduCoverage <- eduATClean %>% 
  filter(Dim1 == "Summary" & Value != "No Information") %>% 
  count(Value)

#graphing how coverage is of total, partial, and no coverage. There is the most with partial coverage, which makes sense as anywere from 1 type to 5 types of training would fit in this category
eduCoverage %>% 
  mutate(Value=factor(Value,levels=c("Total coverage","Partial coverage","No coverage"),ordered=T)) %>%
  ungroup() %>%
  ggplot(aes(x = Value, y = n)) +
  geom_bar(stat = "identity", fill='black') +
  geom_text(aes(label = n), vjust = -0.5, color = "white", size = 3) +
  theme_dark() +
  theme(axis.text.x = element_text(angle = 45, hjust = 1), plot.title = element_text(hjust = 0.5)) + 
scale_y_continuous(limits = c(0, 40)) +
  labs(title = "Coverage", x = "Type of Coverage", y = "Number of Countries")

#summarizing the type of coverage across the entire data set
eduATClean1 <- eduATClean %>% 
  group_by(Dim1) %>% 
  summarise(sumValue = sum(Value == "Yes", na.rm = TRUE)) %>%
  ungroup() %>% 
  filter(Dim1 != "Summary" )


#Most common type of Coverage. Traingin related to mobility and vision are the most common
eduATClean1 %>% 
  ungroup() %>%
  ggplot(aes(x = reorder(Dim1, -sumValue), y = sumValue)) +
  geom_bar(stat = "identity", fill='black') +
  geom_text(aes(label = sumValue), vjust = -0.5, color = "white", size = 3) +
  theme_dark() +
  theme(axis.text.x = element_text(angle = 45, hjust = 1), plot.title = element_text(hjust = 0.5)) + 
  scale_y_continuous(limits = c(0, 50)) +
  labs(title = "Most common type of Coverage", x = "Type of Coverage", y = "Number of Countries")