[R] Transform values from one column into column names of new dataframe

Matt mvgnyc at gmail.com
Fri May 2 18:05:29 CEST 2008


Hi, I have a question about reformatting data. It looks like it should
be simple, but I've been working at it for awhile now and it's about
time I ask for help.

My data look like this:

ITEM VALUE STEP
item1 A          first
item2 C          first
item2 D          second
item1 A          second
item3 A          first
item3 B          second
item3 A          third

I just want to transform it so they look like this:

ITEM FIRST SECOND THIRD
item1 A         A                NA
item2 C         D                NA
item3 A         B                A

Basically taking the values of the "STEP" column and using those as
the column names and merging together the items.

I appreciate your help,
-Matt



More information about the R-help mailing list