Hi! I am new to R and currently working on practice assignments. Whereas I am stuck.
Create a function that will automatically manipulate the variables in any dataframe according to some rules.
The function will take a dataframe as input and return it’s manipulated version.
If the variable is an integer, convert it to numeric.
If the variable is a factor, convert it to a character when the number of levels is bigger than an arbitrary parameter (threshold). Give to that
threshold a default value of 1000.
SO basically, I figured out how to add the first rule, but when I try using else if to add the other rule, I am not able to do it. Also I am not sure how to do the part "when the number of levels is bigger than an arbitrary parameter (threshold). Give value of 1000 to threshold".
Hope my question is clear!
Eager to learn and participate in this community!