surveytidy v0.4.0
New features
Survey-aware transformation functions
Five vector-level transformation functions are now available for converting,
collapsing, and reversing variables inside mutate(). All five propagate value
labels automatically and accept .label and .description arguments to
attach metadata in a single step.
-
make_factor()— converts labelled, numeric, character, or factor vectors
to an Rfactor. Levels are ordered by the numeric value of each value label.
Acceptsordered,drop_levels,force, andna.rmto control level
creation. -
make_dicho()— collapses a multi-level factor to two levels by stripping
the first word of each label and merging labels that reduce to the same
stem. Accepts.excludeto keep specific levels asNA, andflip_levels
to reverse the resulting order. -
make_binary()— converts a dichotomous variable to a 0/1 integer. Thin
wrapper aroundmake_dicho(); acceptsflip_valuesto control which level
maps to 1. -
make_rev()— reverses a numeric scale usingmin + max - xand remaps
value labels to match. Issues a warning when all values areNA. -
make_flip()— reverses the semantic valence of a variable by reversing the
label strings while keeping the underlying values unchanged. Requires a
labelargument to document the new meaning.