Question: Using R, write a function that will take in a quantitative variable and convert it to a categorical one. For example, if the input for
Using R, write a function that will take in a quantitative variable and convert it to a categorical one.
For example, if the input for the function is a vector of numeric ages, the output could be a vector containing character data that specifies the age as old or young, where a person is considered young if they are under 30 years old. To accomplish this the user would have to specify the labels to use (old, young) and the splitting point for the categories (30).
Your job is to create a general-purpose function that can work for any scenario, not just the one described above. Set the default for the labels to be Yes and No.
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
