I am planning to apply Structural Equation Model and I have 5 level likert scale data for my variables (Strongly disagree, disagree, neutral, agree, strongly agree). I am learning R for empirical estimation. When I open my excel data, R reads the responses (Agree, Neutral, Strongly disagree etc) as character that is understandable as the data is in the form of text. After some research I found out that first I need to convert the character variables into factors and then into numeric values. So I did that but R didn't take into account the order of factors. For instance, order should be: Strongly disagree =1, disagree=2, neutral=3, agree=4, strongly agree=5, because I didn't use the levels argument in my command. Now when I use the levels argument, see below:
a3 = as.factor(mydata$qa3, levels = c('Strongly disagree', 'Disagree', 'neutral', 'Agree', 'stringly disagree'))
I am getting the following error.
Error in as.factor(mydata$qa3, levels = c("Strongly disagree", "Disagree", :
unused argument (levels = c("Strongly disagree", "Disagree", "neutral", "Agree", "stringly disagree"))
I have two questions in this regard:
1. How can I convert these characters into ordered numeric for further data analysis?
2. Is there a way I can do it for several variables at once instead of doing it one by one?
Thank You!