Skip to content

Potential weak point in a function #3

Description

@rhi-batstone

Function to create table: Total by sex and year used on the births and deaths datasets: https://github.com/DataScienceScotland/council_area_profiles/blob/7943638a8de52cbcff000f99e589793102d09f0e/34_tables.R#L147-L159

This function uses the min year from the births data. This will be a problem if the births dataset is behind or ahead the deaths dataset. (line 155 & 156)
The function can probably be made more robust by calculating the min year within the function rather than using the variable already created for births start/min year e.g.:

mutate(Perc = ((Total - Total[Year == min(dataset[["Registration Year"]])]) / 
                      Total[Year == min(dataset[["Registration Year"]])]) * 100) %>% 

If the births and deaths data is guaranteed to be updated at the same time then this issue can be disregarded.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions