$30 off During Our Annual Pro Sale. View Details »

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.

Mine Cetinkaya-Rundel

February 18, 2020
Tweet

More Decks by Mine Cetinkaya-Rundel

Other Decks in Education

Transcript

  1. bit.ly/eat-cake-cetl-cerse
    Let them
    eat cake
    (first)!
    mine-cetinkaya-rundel
    [email protected]
    @minebocek
    bit.ly/eat-cake-cetl-cerse
    © Tom Hovey 2018

    View Slide

  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?

    View Slide

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

    View Slide

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

    View Slide

  5. 3
    1
    5
    misconceptions
    context
    design principles

    View Slide

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

    View Slide

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

    View Slide

  8. bit.ly/eat-cake-cetl-cerse
    “Students should learn
    a new programming language starting with
    data structures and algorithms.”

    View Slide

  9. bit.ly/eat-cake-cetl-cerse
    “Students approach a new programming language
    the same way a software engineer does.”

    View Slide

  10. bit.ly/eat-cake-cetl-cerse
    context
    1

    View Slide

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

    View Slide

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

    View Slide

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

    View Slide

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

    View Slide

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

    View Slide

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

    View Slide

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

    View Slide

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

    View Slide

  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

    View Slide

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


    → →

    View Slide

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



    View Slide

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

    View Slide

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

    View Slide

  24. bit.ly/eat-cake-cetl-cerse
    start
    with
    cake
    2

    View Slide

  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

    View Slide

  26. bit.ly/eat-cake-cetl-cerse
    with great examples,
    comes a great amount of code…

    View Slide

  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

    View Slide

  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"
    )

    View Slide

  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"

    View Slide

  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"

    View Slide

  31. bit.ly/eat-cake-cetl-cerse

    View Slide

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

    View Slide

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

    View Slide

  34. bit.ly/eat-cake-cetl-cerse
    skip
    baby
    steps
    3

    View Slide

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

    View Slide

  36. bit.ly/eat-cake-cetl-cerse
    non-trivial examples can be motivating,
    but need to avoid !
    @#$%

    View Slide

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

    View Slide

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

    View Slide

  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

    View Slide

  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

    View Slide

  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")

    View Slide

  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

    View Slide

  43. bit.ly/eat-cake-cetl-cerse
    ggplot(us_votes)

    View Slide

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

    View Slide

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

    View Slide

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

    View Slide

  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"
    )

    View Slide

  48. bit.ly/eat-cake-cetl-cerse
    re-insert
    skip
    baby
    steps

    View Slide

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

    View Slide

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

    View Slide

  51. bit.ly/eat-cake-cetl-cerse
    hide
    the
    veggies
    4

    View Slide

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

    View Slide

  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

    View Slide

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

    View Slide

  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.

    View Slide

  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?

    View Slide

  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

    View Slide

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

    View Slide

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

    View Slide

  60. bit.ly/eat-cake-cetl-cerse
    leverage
    the
    ecosystem
    5

    View Slide

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

    View Slide

  62. bit.ly/eat-cake-cetl-cerse
    Let them eat cake (first)!*
    mine-cetinkaya-rundel
    [email protected]
    @minebocek
    * You can tell them all about
    the ingredients later!
    bit.ly/eat-cake-cetl-cerse
    bit.ly/repo-eat-cake

    View Slide