I loaded data from a CSV file into a data frame. Each column is a survey question, and all answers refer to the five-point Likert scale with labels: ("No", "Low", "Medium", "High", "Very High").
When I read the data first, R correctly interprets these values as factors, but does not know what should be ordering. I want to indicate what the order is for the values, so I can do some numerical calculations. I thought the following code would work:
X <- read.csv('..')
likerts <- data.frame(apply(X, 2, function(X){factor(X,
levels = c("None", "Low", "Medium", "High", "Very High"),
ordered = T)}))
Instead, all level data is converted to rows. How to do it right?
source
share