How do I add a column to a dataframe in R based on values in another column of a dataframe ?
For eg if I have one column as x$n = [1,2,3,4,5,6] (values in other colums dont exactly matter. And I want another column as a 'category' column that assigns value 0 if x$n < 2, 1 if x$n is between 3 and 4 and 3 if x$n > 4. So that my corresponding column would be x$category = [0,0,1,1,2,2]