Women in the Workplace

Interactive scatterplot (plotly and shiny packages)

Published

March 4, 2019

Notable topics: Interactive scatterplot (plotly and shiny packages)

Recorded on: 2019-03-04

Timestamps by: Alex Cookson

View code

Screencast

Timestamps

Writing a custom function that summarizes variables based on their names (then abandoning the idea)

complete.cases

Using complete.cases function to find observations that have an NA value in any variable

Using subsetting within a summarise function to calculate a weighted mean when dealing with 0 or NA values in some observations

Debugging what is causing NA values to appear in the summarise output (finds the error at 13:25)

Hypothesizing about one sector illustrating a variation of Simpson's Paradox

scale_colour_gradient2

Creating a scatterplot with a logarithmic scale and using scale_colour_gradient2 function to encode data to point colour

ggplotly
plotly

Creating an interactive plot (tooltips show up on hover) using ggplotly function from plotly package

Fiddling with scale_size_continuous function's range argument to specify point size on a scatterplot (which are encoded to total workers)

Explanation of why healthcare sector is a good example of Simpson's Paradox

shiny

Starting to create a shiny app with "occupation" as only input (many tweaks in subsequent minutes to make it work)

shiny

Tweaking size (height) of graph in shiny app

Summary of screencast