Dear S-Users,
I wonder whether I can create a new factor column with new categories and names derived from a column with numeric values. For example, I wish to have four categories of the following form and names(firstcat, secondcat, thirdcat, fourthcat):
Between -1 and 1: firstcat
Between -2 and -1 or between 1 and 2: secondcat
Between -5 and -2 or between 2 and 5: thirdcat
Below -5 or more than 5: fourthcat
I have looked at functions cut, factor etc but do not know how to use them for my purpose.
Sincerely hope to have some assistance.
Thank you.
Best Regards,
Weiyang
|