Public-Health-Scotland / phsmethods

An R package to standardise methods used in Public Health Scotland (https://public-health-scotland.github.io/phsmethods/)
https://public-health-scotland.github.io/phsmethods/
54 stars 13 forks source link

Function to extract sex from CHI #43

Closed Moohan closed 3 years ago

Moohan commented 4 years ago

Related to the other issue I just added #42 but much simpler as there's no ambiguity with sex in the CHI number.

UoE implementation My implementation for the data I'm working on there it returns a factor. I think default behaviour should be to return 1/2 with maybe an option to return as a factor.

Moohan commented 4 years ago

I've been using these loads recently and have had a slightly different implementation every time so I bit the bullet and wrote up one for here. See the branch here, it's probably a bit over-engineered but it runs quickly and does everything I have needed recently (different values for M/F, factor, automatic CHI checking so that I don't get sex for an invalid CHI.

Happy to take any comments on anything, if no one has anything broad in the next week or so I'll submit it as a PR for review.

Not sure when I'll have time to do #42 which is related but more complicated.