Skip to content

data.frame, converting row data to columns

4 messages · david hilton shanabrook, Hadley Wickham, jim holtman

#
On Sat, Apr 4, 2009 at 12:09 PM, ds <dhshanab at acad.umass.edu> wrote:
cast(x, ... ~ nLevel) ?

If that doesn't work, please provide a minimal reproducible example.

Hadley
#
Does this do what you want:
+ 1                    4094          3.34                    1   frustrated
+ 2                    4094          3.94                    1  frustrated
+ 3                    4094            NA                    1   frustrated
+ 4                    4094          3.51                    1   frustrated
+ 5                    4094          3.81                    1   frustrated
+ 6                    4101          2.62                    4   excited
+ 7                    4094          2.65                    1   frustrated
+ 8                    4101            NA                    4   excited
+ 9                    4101          0.24                    4   excited
+ 10                   4101          0.23                    4
excited"), header=TRUE)
name nLevel       emot    1    2    3    4    5    6
1 4094      1 frustrated 3.34 3.94   NA 3.51 3.81 2.65
2 4101      4    excited 2.62   NA 0.24 0.23   NA   NA
On Sat, Apr 4, 2009 at 1:09 PM, ds <dhshanab at acad.umass.edu> wrote:

  
    
#
On Sat, Apr 4, 2009 at 12:28 PM, jim holtman <jholtman at gmail.com> wrote:
which you can abbreviate to :

cast(y, ... ~ indx)

... means all the other variables not explicitly mentioned.

Hadley