Skip to content

Commit 7c7cb9a

Browse files
sbfnksbfnk-bot
andcommitted
Deprecate missing_contact_age = 'sample' option
The 'sample' option requires the participant-contact merge to have happened first, which prevents modular pre-processing of survey data. Users should use 'remove', 'keep', or 'ignore' instead. Fixes #273 Co-authored-by: sbfnk-bot <242615673+sbfnk-bot@users.noreply.github.com>
1 parent a32ecd1 commit 7c7cb9a

File tree

4 files changed

+26
-1
lines changed

4 files changed

+26
-1
lines changed

NEWS.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,8 @@
2626

2727
## Deprecations
2828

29+
* The `missing_contact_age = "sample"` option in `contact_matrix()` and `assign_age_groups()` has been soft-deprecated and will be removed in a future version. Use `"remove"` to exclude contacts with missing ages, `"keep"` to retain them as a separate age group, or `"ignore"` to drop only those contacts (#273).
30+
2931
* Argument names with dots (e.g., `age.limits`) have been deprecated in favour of underscores (e.g., `age_limits`) in `contact_matrix()`, `as_contact_survey()`, `pop_age()`, and `clean()`. The old argument names still work but will produce deprecation warnings (#160).
3032

3133
* We have soft-deprecated `get_survey()`, `download_survey()`, `get_citation()` and `list_surveys()` and moved these to [contactsurveys](https://github.com/epiforecasts/contactsurveys). We have also soft-deprecated `survey_countries()` as this called `get_survey()` internally. This is part of decoupling these features from socialmixr to reduce dependencies (#207 and #179). These will continue to be supported until we move to a major release (version 1.0.0) of socialmixr. In the meantime, we recommend that users use the [contactsurveys](https://github.com/epiforecasts/contactsurveys) package, as these functions have improved caching and support there.

R/assign-age-groups.R

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,18 @@ assign_age_groups <- function(
5454
missing_participant_age <- rlang::arg_match(missing_participant_age)
5555
missing_contact_age <- rlang::arg_match(missing_contact_age)
5656

57+
if (missing_contact_age == "sample") {
58+
lifecycle::deprecate_warn(
59+
"0.5.0",
60+
"assign_age_groups(missing_contact_age = 'sample')",
61+
details = paste(
62+
"Sampling missing contact ages will be removed in a future version.",
63+
"Use 'remove' to exclude contacts with missing ages, 'keep' to retain",
64+
"them as a separate age group, or 'ignore' to drop only those contacts."
65+
)
66+
)
67+
}
68+
5769
## set contact age and participant age if it's not in the data
5870
survey$participants <- add_part_age(survey$participants)
5971
survey$contacts <- add_contact_age(survey$contacts)

R/contact_matrix.R

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -211,6 +211,18 @@ contact_matrix <- function(
211211
missing_participant_age <- match.arg(missing_participant_age)
212212
missing_contact_age <- match.arg(missing_contact_age)
213213

214+
if (missing_contact_age == "sample") {
215+
lifecycle::deprecate_warn(
216+
"0.5.0",
217+
"contact_matrix(missing_contact_age = 'sample')",
218+
details = paste(
219+
"Sampling missing contact ages will be removed in a future version.",
220+
"Use 'remove' to exclude contacts with missing ages, 'keep' to retain",
221+
"them as a separate age group, or 'ignore' to drop only those contacts."
222+
)
223+
)
224+
}
225+
214226
survey <- copy(survey)
215227

216228
check_if_contact_survey(survey)

R/globals.R

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,6 @@ utils::globalVariables(c(
9494
"..original.lower.age.limit", # <pop_age>
9595
"..segment", # <pop_age>
9696
"..upper.age.limit", # <pop_age>
97-
"population", # <pop_age>
9897
"population", # <survey_country_population>
9998
"sex", # <wpp_age>
10099
"country", # <wpp_age>

0 commit comments

Comments
 (0)