Skip to content

04, "percent of each house type" #68

Closed
@dhicks

Description

In the Barplot section of the ggplot lesson, the narrative text says that we want to create a dataframe with "the percent of each house type in each village." However, the code calculates percentages across the entire dataset, not by village. Note that the totals for each village are clearly well below 100%.

The code should be

percent_wall_type <- interviews_plotting %>%
    filter(respondent_wall_type != "cement") %>%
    count(village, respondent_wall_type) %>%
    group_by(village) %>%
    mutate(percent = n / sum(n))
    ungroup()

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions