-1

I made a survey with answers such as "Extremely important", "Moderately important", "Not at all" answers. I put the survey in an excel sheet that I put on R.

I want to use the ANOVA (one way) test to examine the link between one answer and the gender of the people answering the survey.

But I can't find the mean when using the aggregate function because the answers from the survey are not numerical. I need to convert extremely important into 5, Very important into 4, ect ...

How could it be possible ? Thanks for your help and your time.

enter image description here

enter image description here

Phil
  • 7,287
  • 3
  • 36
  • 66
  • 1
    Welcome to SO! To help us to help you, would you mind providing [a minimal reproducible example](https://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example) including a snippet of your data and the code you tried. Please do not add images of your code/data/errors [for these reasons](https://meta.stackoverflow.com/questions/285551/why-not-upload-images-of-code-errors-when-asking-a-question/285557#285557). – stefan Dec 01 '21 at 21:29

1 Answers1

0

There are a couple of ways you could do this. The first that comes to mind would be to convert the character vector into an ordered factor and then to a numeric like so:

# suppose your scores vector looks like this:
scores <- c('Extremely Important', 'Very Important', 'Moderately Important', 'Sort of Important', 'Not Important')

as.numeric(factor(scores, levels = c('Not Important', 'Sort of Important', 'Moderately Important', 'Very Important',  'Extremely Important')))

The first value of levels will be assigned a value of 1, ...