Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Let them eat cake (first)!

Let them eat cake (first)!

Talk updated for 2020, delivered at the 5th Community of Edinburgh Research Software Engineers (CERSE) meeting.

81689b093f75cf3f383e581ca57188df?s=128

Mine Cetinkaya-Rundel

February 18, 2020
Tweet

Transcript

  1. bit.ly/eat-cake-cetl-cerse Let them eat cake (first)! mine-cetinkaya-rundel mcetinka@ed.ac.uk @minebocek bit.ly/eat-cake-cetl-cerse

    © Tom Hovey 2018
  2. bit.ly/eat-cake-cetl-cerse Q Imagine you’re new to baking, and you’re in

    a baking class. I’m going to present two options for starting the class. Which one gives you better sense of the final product?
  3. Pineapple and Coconut Sandwich Cake bit.ly/eat-cake-cetl-msor

  4. Pineapple and Coconut Sandwich Cake bit.ly/eat-cake-cetl-msor

  5. 3 1 5 misconceptions context design principles

  6. bit.ly/eat-cake-cetl-cerse miscon- ceptions 3

  7. bit.ly/eat-cake-cetl-cerse “Students should learn a new programming language in the

    order in which it’s been taught forever.”
  8. bit.ly/eat-cake-cetl-cerse “Students should learn a new programming language starting with

    data structures and algorithms.”
  9. bit.ly/eat-cake-cetl-cerse “Students approach a new programming language the same way

    a software engineer does.”
  10. bit.ly/eat-cake-cetl-cerse context 1

  11. bit.ly/eat-cake-cetl-cerse introds.org

  12. bit.ly/eat-cake-cetl-cerse introds.org

  13. bit.ly/eat-cake-cetl-cerse introds.org

  14. bit.ly/eat-cake-cetl-cerse introds.org

  15. bit.ly/eat-cake-cetl-cerse design principles 5

  16. bit.ly/eat-cake-cetl-cerse Q Which kitchen would you rather bake a cake?

  17. bit.ly/eat-cake-cetl-cerse Q Which kitchen would you rather bake a cake?

  18. bit.ly/eat-cake-cetl-cerse cherish day one 1

  19. bit.ly/eat-cake-cetl-cerse Go to RStudio in the cloud Log in with

    your ID & pass > hello R! Install R Install RStudio Install the following packages: tidyverse rmarkdown … Load these packages Install git
  20. bit.ly/eat-cake-cetl-cerse → → → → → → →

  21. bit.ly/eat-cake-cetl-cerse → → → → → →

  22. bit.ly/eat-cake-cetl-cerse Q How do you prefer your cake recipes? Words

    only, or words & pictures?
  23. bit.ly/eat-cake-cetl-cerse Q How do you prefer your cake recipes? Words

    only, or words & pictures? —
  24. bit.ly/eat-cake-cetl-cerse start with cake 2

  25. bit.ly/eat-cake-cetl-cerse # Declare variables x <- 8 y <- "monkey"

    z <- FALSE class(x) #> [1] "numeric" class(y) #> [1] “character" class(z) #> [1] "logical" Declare the following variables Then, determine the class of each variable Open today’s demo project Knit the document and discuss the results with your neighbor Then, change Turkey to a different country, and plot again
  26. bit.ly/eat-cake-cetl-cerse with great examples, comes a great amount of code…

  27. bit.ly/eat-cake-cetl-cerse but let’s focus on the task at hand… Open

    today’s demo project Knit the document and discuss the results with your neighbor Then, change Turkey to a different country, and plot again
  28. un_votes %>% filter(country %in% c("UK & NI", “US”, "Turkey")) %>%

    inner_join(un_roll_calls, by = "rcid") %>% inner_join(un_roll_call_issues, by = "rcid") %>% group_by(country, year = year(date), issue) %>% summarize( votes = n(), percent_yes = mean(vote == "yes") ) %>% filter(votes > 5) %>% # only use records where there are more than 5 votes ggplot(mapping = aes(x = year, y = percent_yes, color = country)) + geom_smooth(method = "loess", se = FALSE) + facet_wrap(~ issue) + labs( title = "Percentage of Yes votes in the UN General Assembly", subtitle = "1946 to 2015", y = "% Yes", x = "Year", color = "Country" )
  29. un_votes %>% filter(country %in% c("UK & NI", “US”, "Turkey")) %>%

    inner_join(un_roll_calls, by = "rcid") %>% inner_join(un_roll_call_issues, by = "rcid") %>% group_by(country, year = year(date), issue) %>% summarize( votes = n(), percent_yes = mean(vote == "yes") ) %>% filter(votes > 5) %>% # only use records where there are more than 5 votes ggplot(mapping = aes(x = year, y = percent_yes, color = country)) + geom_smooth(method = "loess", se = FALSE) + facet_wrap(~ issue) + labs( title = "Percentage of Yes votes in the UN General Assembly", subtitle = "1946 to 2015", y = "% Yes", x = "Year", color = "Country" ) "Turkey"
  30. un_votes %>% filter(country %in% c("UK & NI", “US”, “France")) %>%

    inner_join(un_roll_calls, by = "rcid") %>% inner_join(un_roll_call_issues, by = "rcid") %>% group_by(country, year = year(date), issue) %>% summarize( votes = n(), percent_yes = mean(vote == "yes") ) %>% filter(votes > 5) %>% # only use records where there are more than 5 votes ggplot(mapping = aes(x = year, y = percent_yes, color = country)) + geom_smooth(method = "loess", se = FALSE) + facet_wrap(~ issue) + labs( title = "Percentage of Yes votes in the UN General Assembly", subtitle = "1946 to 2015", y = "% Yes", x = "Year", color = "Country" ) "France"
  31. bit.ly/eat-cake-cetl-cerse

  32. bit.ly/eat-cake-cetl-cerse Q Which motivates you more to learn how to

    cook: perfectly chopped onions or ratatouille?
  33. bit.ly/eat-cake-cetl-cerse Q Which motivates you more to learn how to

    cook: perfectly chopped onions or ratatouille? —
  34. bit.ly/eat-cake-cetl-cerse skip baby steps 3

  35. bit.ly/eat-cake-cetl-cerse Create a visualization displaying whether the vote was on

    an amendment.
  36. bit.ly/eat-cake-cetl-cerse non-trivial examples can be motivating, but need to avoid

    ! @#$%
  37. bit.ly/eat-cake-cetl-cerse @#$% scaffold + layer

  38. bit.ly/eat-cake-cetl-cerse Write it out to your heart’s desire and polish

    it
  39. bit.ly/eat-cake-cetl-cerse Write it out to your heart’s desire and polish

    it Split into three parts pre-process stash ✅ feature
  40. bit.ly/eat-cake-cetl-cerse Write it out to your heart’s desire and polish

    it Split into three parts pre-process stash ✅ feature Decide on pace at which to scaffold and later
  41. bit.ly/eat-cake-cetl-cerse un_votes %>% filter(country %in% c("United States of America")) %>%

    inner_join(un_roll_calls, by = "rcid") %>% inner_join(un_roll_call_issues, by = "rcid") %>% mutate( importantvote = ifelse(importantvote == 0, "No", "Yes"), issue = ifelse(issue == "Nuclear weapons and nuclear material", "Nuclear weapons and materials", issue) ) %>% ggplot(aes(y = importantvote, fill = vote)) + geom_bar(position = "fill") + facet_wrap(~ issue, ncol = 1) + labs( title = "How the US voted in the UN", subtitle = "By issue and importance of vote", x = "Important vote", y = "", fill = "Vote" ) + theme_minimal() + scale_fill_viridis_d(option = "E")
  42. bit.ly/eat-cake-cetl-cerse un_votes %>% filter(country %in% c("United States of America")) %>%

    inner_join(un_roll_calls, by = "rcid") %>% inner_join(un_roll_call_issues, by = "rcid") %>% mutate( importantvote = ifelse(importantvote == 0, "No", "Yes"), issue = ifelse(issue == "Nuclear weapons and nuclear material", "Nuclear weapons and materials", issue) ) %>% ggplot(aes(y = importantvote, fill = vote)) + geom_bar(position = "fill") + facet_wrap(~ issue, ncol = 1) + labs( title = "How the US voted in the UN", subtitle = "By issue and importance of vote", x = "Important vote", y = "", fill = "Vote" ) + theme_minimal() + scale_fill_viridis_d(option = "E") pre-process stash ✅ feature us_votes
  43. bit.ly/eat-cake-cetl-cerse ggplot(us_votes)

  44. bit.ly/eat-cake-cetl-cerse ggplot(us_votes, aes(y = importantvote, fill = vote))

  45. bit.ly/eat-cake-cetl-cerse ggplot(us_votes, aes(y = importantvote, fill = vote)) + geom_bar(position

    = "fill")
  46. bit.ly/eat-cake-cetl-cerse ggplot(us_votes, aes(y = importantvote, fill = vote)) + geom_bar(position

    = "fill") + facet_wrap(~ issue, ncol = 1)
  47. bit.ly/eat-cake-cetl-cerse ggplot(us_votes, aes(y = importantvote, fill = vote)) + geom_bar(position

    = "fill") + facet_wrap(~ issue, ncol = 1) + labs( title = "How the US voted in the UN", subtitle = "By issue and importance of vote", x = "Important vote", y = "", fill = "Vote" )
  48. bit.ly/eat-cake-cetl-cerse re-insert skip baby steps

  49. bit.ly/eat-cake-cetl-cerse Q Which is more likely to appeal to someone

    who has never tried broccoli?
  50. bit.ly/eat-cake-cetl-cerse Q Which is more likely to appeal to someone

    who has never tried broccoli? —
  51. bit.ly/eat-cake-cetl-cerse hide the veggies 4

  52. bit.ly/eat-cake-cetl-cerse Topic: Web scraping Tools: rvest regular expressions Today we

    start with this: and end with this:
  53. bit.ly/eat-cake-cetl-cerse students will encounter lots of new challenges along the

    way — let that happen, and then provide a solution
  54. bit.ly/eat-cake-cetl-cerse Lesson: Web scraping essentials for turning a structured table

    into a data frame in R.
  55. bit.ly/eat-cake-cetl-cerse Lesson: Web scraping essentials for turning a structured table

    into a data frame in R. Ex 1: Scrape the table off the web and save as a data frame.
  56. bit.ly/eat-cake-cetl-cerse Lesson: Web scraping essentials for turning a structured table

    into a data frame in R. Ex 1: Scrape the table off the web and save as a data frame. Ex 2: What other information do we need represented as variables to build the following visualisation?
  57. bit.ly/eat-cake-cetl-cerse Lesson: Web scraping essentials for turning a structured table

    into a data frame in R. Ex 1: Scrape the table off the web and save as a data frame. Lesson: “Just enough” string parsing and regular expressions to go from Ex 2: What other information do we need represented as variables to build the following visualisation? to
  58. bit.ly/eat-cake-cetl-cerse Q If you are already taking a baking class,

    which will be easier to venture on to?
  59. bit.ly/eat-cake-cetl-cerse Q If you are already taking a baking class,

    which will be easier to venture on to? —
  60. bit.ly/eat-cake-cetl-cerse leverage the ecosystem 5

  61. bit.ly/eat-cake-cetl-cerse student + instructor instructor learnr ...

  62. bit.ly/eat-cake-cetl-cerse Let them eat cake (first)!* mine-cetinkaya-rundel mcetinka@ed.ac.uk @minebocek *

    You can tell them all about the ingredients later! bit.ly/eat-cake-cetl-cerse bit.ly/repo-eat-cake