Fix IDs with NAs + new attrition function#76
Merged
bernardo-sieira merged 4 commits intomasterfrom Mar 23, 2026
Merged
Conversation
Basically: dat$id_rs <- ifelse(
is.na(dat$id_rs),
NA_character_,
paste0(as.hexmode(dat$V1014), as.hexmode(dat$id_rs))
) using ifelse we are able to set all of the cases where we would have a combination with NA in the id_rs to NA directly
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Not yet working. Problem diagnosis: pasting as.hexmode() for panel and id pastes NA ids, resulting in 300k/2.8M identifiers being 6NA for panel 6. Instead, they should be just NA. I already tried a vectorized validity check approach, but it did not work: I ran the panel again with this new code and I still have the same 6NA ids.
@bernardo-sieira please help!! First check whether the code we currently have makes sense (let me knwo what your AIs suggest), then solve it and test is please.
I also included a new attrition calculation function I believe makes more sense than
cria_df_de_atrito. It returns three different percentage_found rates: the unconditional one corresponds to the one we previously had - what % of ids appearing in 1 appear in 2, what % appearing in 1 appears in 3, etc. The conditional ones correspond to what % of ids appearing in 1 appear in 2 (this one coincides with unconditional), what % os ids appearing in 1 AND 2 appear in 3, what % of ids appearing in 1 AND 2 AND 3 appear in 4, etc. For the conditional attrition we have two denominator options: the number of ids found in wave/entrevista 1 OR the number of ids found in the previous wave/entrevista. Notive the former is mehcnically decreasing whereas the latter can be whatever