How to transform into numerical data?

VERY new to R.
As in, it took me 1 hour to work around my data <- read.csv("filename.csv") error, type of new to R (apparently my working directory has to be refreshed each time I open R, if you were curious).

I have 3 data columns filled with 50 rows of Yes/No answers (column names= Score1, Score2, Score3) and I need to transform the answers in those 3 columns into numbers where Yes=1, No=2.
Downloaded and loaded tidyverse.
As far as I understand, I should be able to use the transform or mutate function, but no amount of reading into those functions helps me understand how I should be able to use them in reference to my specific dataset.
Any and all help would be highly appreciated

**loaded magrittr

Something like

library(magritter)
data  %<>% mutate(newScore1 = ifelse(Score1 == "Yes",1,0)

Notice that this translates any error where the answer is neither "Yes" nor "No" into "No." That might or might not be what you want.

1 Like

literally speechless with gratitude. I think this is the first line of code that worked smoothly without any errors
do you accept paypal

yes i understand, i was just joking :grin:

:grinning:
Hearing that my reply helped is appreciated though!

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.