When using the code below, I change a quantitative variable to a categorical variable. BUT, the new variable replaces the old quantitative variable, as I am using the cut() command.
Can someone please tell me how to perform the same task of changing the quantitative variable to a categorical variable but ADD the new variable as a column to the data frame AND keep the existing quantitative variable column.
If you converted a numeric variable to a group variable, whatever be its label, you're loosing information. You cannot go back to original information only from the newly available information.
In the first step, you could do something like this:
@TyeGalloway, did you try my solution? It'll do what you want.
mutate isn't magic. It won't be able to get information which is lost. But if you are tidyverse only person, here's the equivalent line of my above code with mutate and pipe operator:
Hi @Yarnabrina,
Thank you so much for taking the time to help with my question.
I am really after something like the mutate() function, whereby the original columns remain but a new computed column is added.
Can you help with this?