[1] FALSE FALSE FALSE TRUE TRUE TRUE
Lecture 10
College of Idaho
CSCI 2025 - Winter 2026
TRUE, FALSE, and NA (missing) values.> (greater than), < (less than)>= (greater than or equal to), <= (less than or equal to)== (equal to), != (not equal to)filter()filter() to select rows.flights dataset to find flights that were delayed on arrival.== with numbers. Computers can have small rounding errors.near() from the dply package to compare two numbers for “close enough” equality.NANA represents a missing value.NA is “contagious”: almost any operation involving NA will produce NA.== to find missing values.is.na()is.na() function to test if a value is missing.NAfilter() only includes rows where the condition is TRUE. It excludes FALSE and NA values.drop_na to remove rows with missing values.Let’s do some practice!
& (and)| (or)! (not)%in%x == a | x == b | x == c is x %in% c(a, b, c).TRUE becomes 1 and FALSE becomes 0.sum(): counts the number of TRUEs.mean(): calculates the proportion of TRUEs.if_else()if_else(condition, value_if_true, value_if_false)case_when()case_when() is easier to read than nested if_else().case_when(condition1 ~ value1, condition2 ~ value2, ...)TRUE condition wins.case_when()<, ==, %in%, is.na().&, |, !.any(), all(), sum(), mean().if_else() and case_when().