Skip to content

Improving missing values operation explanation in boolean algebra section#1712

Merged
mine-cetinkaya-rundel merged 1 commit intohadley:mainfrom
davidrsch:missing_val_expla
Apr 29, 2025
Merged

Improving missing values operation explanation in boolean algebra section#1712
mine-cetinkaya-rundel merged 1 commit intohadley:mainfrom
davidrsch:missing_val_expla

Conversation

@davidrsch
Copy link
Copy Markdown
Contributor

Previous explanation

To understand what's going on, think about NA | TRUE (NA or TRUE). A missing value in a logical vector means that the value could either be TRUE or FALSE. TRUE | TRUE and FALSE | TRUE are both TRUE because at least one of them is TRUE. NA | TRUE must also be TRUE because NA can either be TRUE or FALSE. However, NA | FALSE is NA because we don't know if NA is TRUE or FALSE. Similar reasoning applies with NA & FALSE

The last sentence of previous explanation implies that NA & FALSE returns NA as NA | FALSE, explained in previous sentence. Therefore a more detailed explanation explaining how the similar reasoning is applied when using & but taking into consideration that both conditions must be fulfilled.

To understand what's going on, think about NA | TRUE (NA or TRUE). A missing value in a logical vector means that the value could either be TRUE or FALSE. TRUE | TRUE and FALSE | TRUE are both TRUE because at least one of them is TRUE. NA | TRUE must also be TRUE because NA can either be TRUE or FALSE. However, NA | FALSE is NA because we don't know if NA is TRUE or FALSE. Similar reasoning applies for & considering that both conditions must be fulfilled. Therefore NA & TRUE is NA because NA can either be TRUE or FALSE and NA & FALSE is FALSE because at least one of the conditions is FALSE.

@mine-cetinkaya-rundel mine-cetinkaya-rundel merged commit 8412c21 into hadley:main Apr 29, 2025
1 of 2 checks passed
@mine-cetinkaya-rundel
Copy link
Copy Markdown
Collaborator

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants