Closed alvinthomas closed 3 months ago
Closing the issue since a general solution was identified. Please re-open if this doesn't work for future data structure checks. A potential enhancement is a more flexible check of the data structure.
This is great! I think we can set up a more explicit set of global exclusions going forward that will drop missings in apoe4
and time
+ status
, then restrict analysis to adults 55 and older (or whatever cut-point works globally).
There are checks for the values/format of the variables sex and apoe4 that were tripping me up. I found it easiest to make these into labelled factor variables.
This assumes the values of your data are current "female" and "male" for sex and "carrier" and "non_carrier" for apoe4. It also allows for you to have missingness in sex and apoe4. However, since we aren't allowed to have missing apoe4 values, the last step filters out those that are missing apoe4 status.
Replace zzzz with the name of your data object. This process can be part of data_prepare (since the levels are first checked there).
Example code: