我想你的意思是这样的......
# Make some reproducible data
set.seed(123)
df <- data.frame( replicate( 6 , sample( c("strdisag", "disagree", "neutral","agree","stragree") , 5 , repl = TRUE ) ) )
# Unordered factor variable
df[,1]
[1] disagree agree neutral stragree stragree
Levels: agree disagree neutral stragree
# Make list of ordered factor variables
out <- lapply( df , function(x) ordered(x, levels = c("strdisag", "disagree", "neutral","agree","stragree") ) )
# Combine into data.frame
res <- do.call( data.frame , out )
X1 X2 X3 X4 X5 X6
1 disagree strdisag stragree stragree stragree agree
2 agree neutral neutral disagree agree neutral
3 neutral stragree agree strdisag agree neutral
4 stragree neutral neutral disagree stragree disagree
5 stragree neutral strdisag stragree agree strdisag
# Check result
res[,1]
[1] disagree agree neutral stragree stragree
Levels: strdisag < disagree < neutral < agree < stragree