Survey exports are littered with empty strings and standard "non-answer"
options such as "Prefer not to answer". This helper turns those into real
NA values so they drop out of counts and summaries, replacing the
repetitive filter(x != "", x != "Prefer not to answer") idiom.
Arguments
- x
A character (or factor) vector.
- also
Additional exact strings to treat as missing. Defaults to the
na_answersoption ("Prefer not to answer"; seeezrsurvey_options()). Set tocharacter(0)to only blank out"".- trim
Whether to trim surrounding whitespace before comparing. Defaults to
TRUE.
Details
The input is coerced to character (so factors are handled), optionally
whitespace-trimmed, and any value equal to "" or to one of also becomes
NA. The default also reads the na_answers option, so you can change what
counts as a non-answer package-wide with
ezrsurvey_options(na_answers = ...). Most of the calc_* helpers call
na_blank() internally when na_rm = TRUE, so you usually get this clean-up
for free; call it directly when you want to blank a column in a pipeline.
