Skip to content

Help converting a data.frame to ordered factors

4 messages · Robert Cassidy, Phil Spector, Rob Cassidy

#
I have a 96x34 array of Likert scale data (96 cases, 34 items) of
ordered factors (strongly disagree, disagree, neutral, agree, strongly
agree) that are coded numerically (1 through 5).

I cannot seem to convert this array (in any class) into ordered vectors.

I have all the cases as vectors of ordered factors, but any which way
I reassemble those vectors loses the ordered factors and converts back
to numbers.

Can someone tell me how to either convert the data.frame into ordered
factors OR how to assemble the vectors (of ordered factors) into an
array that preserves the factors.

Many thanks in advance for any help.
Robert
#
Robert -
    It would be helpful to know what you've tried that didn't
work, but the data.frame() function is the usual way of combining
things like this:
a         b 
[1,] "ordered" "ordered"
[2,] "factor"  "factor"

In particular cbind() and matrix() will not work properly for
what you're trying to do.

Of course, if you explained exactly how you're creating the 
96x34 array, there might be a better solution.

 					- Phil Spector
 					 Statistical Computing Facility
 					 Department of Statistics
 					 UC Berkeley
 					 spector at stat.berkeley.edu
On Mon, 2 May 2011, Robert Cassidy wrote:

            
#
Hi again,
Now that I have the data.frame as ordered factors, when I try to transpose
it, I lose the factor orders.
c1        c2        c96      
[1,] "ordered" "ordered" "ordered"
[2,] "factor"  "factor"  "factor"
item1    item2    item3    item4   ...
"factor" "factor" "factor" "factor" ...
Is there a simple way to re-impose ordering on the transposed df? or
alternatively to transpose the df without losing the ordering?

Many thanks,
Robert

--
View this message in context: http://r.789695.n4.nabble.com/Help-converting-a-data-frame-to-ordered-factors-tp3490838p3492979.html
Sent from the R help mailing list archive at Nabble.com.