[R] I need help for creating a "timevar"

kbr kb at flicon.de
Mon Jul 4 15:41:33 CEST 2011


Hi all!

I have data in „Long“ format which I would like to reshape to „Wide“. I know
that one possibility is the „reshape“ command, which needs a „timevar“.

Data look as follows: There are approx. 3000 persons („IDENTITY“) and, for
each person, there are between 2 and 20 events („EVENT“).  For now, there's
one row for each event (9506 rows)

http://r.789695.n4.nabble.com/file/n3643658/Screenshot-2.png 

What is missing is the „timevar“ (SPSS calls it „INDEX“), which numbers the
events WITHIN each person (right column).

I managed to number the events from 1 to 9506 with the seq-command, first
writing the number of rows in nEVENT:
> number <-seq(file=event, 1, nEVENT, b=1) 
Yet, I didn't manage to do so for each individual separately. I guess it
would be possible with the „split“ command, but I can't figure out how to
apply it.

Can anyone give me a hint?
Thank you!

Karen

--
View this message in context: http://r.789695.n4.nabble.com/I-need-help-for-creating-a-timevar-tp3643658p3643658.html
Sent from the R help mailing list archive at Nabble.com.



More information about the R-help mailing list