0

I have a dataset of 2,407 entries, 14 total columns, I called it rtpj. I am trying to add a column of numeric values called 'agent' to the dataset based on the values in my 'conditions' column. The 'conditions' column values are either 1st_P_harm, 1st_P_neut, 3rd_P_harm, 3rd_P_neut, comp_other, or comp_self. I would like to change them to numeric values of 1,2,3,4,5,6 respectively. I have tried

rtpj$conditions = as.numeric(rtpj$conditions)

and I get a warning about NAs. Sure enough, after I did this all the values in my 'conditions' column turned to NA, which makes sense since I haven't assigned any of the 6 possible conditions to a numeric value. How do I do this? I think I am missing some crucial step.

  • First. Do NOT make assignments of a transformation back to the original variable. Doing so means you now need to repeat whatever data entry tasks up to this point to get back the `conditions` column since they are now all NA. Instead (after redo the dataset construction to this point) do this: `rtpj$cond_num – IRTFM Dec 11 '21 at 20:56

0 Answers0