0

I have a data set I'm working with in R and it has 138 entries. One of the questions I am working with is in the form of a character, and is from a survey where people can respond if they are introverts or extroverts.

How can I change every entry of this question to a number i.e. Introvert = 1, Extrovert = 2

I tried to convert it to a factor but the result was this: $ Personality: Factor w/ 0 levels: NA NA NA NA NA NA NA NA NA NA ...

Any ideas?

Here is the str(classdata20): 
'data.frame':   138 obs. of  3 variables:
 $ GPA        : num  3.3 3.3 3.3 3.4 3 3.25 3.3 3.8 3.3 3.6 ...
 $ Personality: Factor w/ 0 levels: NA NA NA NA NA NA NA NA NA NA ...
 $ Income     : num  3000000 150000 500000 250000 500000 120000 120000 1000000 200000 
 200000 ...
  • You can try : `classdata20$Personality <- dplyr::recode(classdata20$Personality, 'Introvert' = 1, 'Extrovert = 2')` – Ronak Shah Dec 07 '20 at 02:05
  • Hi Ronak, I believe that worked! Thank you very much for the help here, I was struggling to do a correlation test and now I think it will finally work. – The31598 Dec 07 '20 at 03:05

0 Answers0