[R] reshape without timevar argument?

Gabor Grothendieck ggrothendieck at myway.com
Sat Feb 26 08:49:53 CET 2005


Tiago R Magalhaes <tiago17 <at> socrates.Berkeley.EDU> writes:

: I have a data.frame with 2 columns. The first column is an ID column. 
: The other columns are description of the ids. There is more than one 
: description for each Id.
: Want I want to get as a value is a data.frame where each row 
: corresponds to one ID and has as many columns as different 
: descriptions.
: 
: I have used a very convoluted step, but I'm very convinced there is 
: an easier way to do this.
: 
: Basically, I used the reshape function, but even in this convulated 
: way there is a step that I can't solve. I used a "fake" timevar using 
: the table function.
: 
: df <- data.frame(id=c(rep('IDa',3), rep('IDb', 5), rep('IDc', 2),
:                     rep('IDd',5)), let=letters[1:5])

table(df) gives a table of zeros and ones corresponding to the 
incidence matrix of IDs vs. descriptions.  Is that sufficient?




More information about the R-help mailing list