[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]
st: RE: Just another data reshaping problem
gen id = _n
> -----Original Message-----
> From: Nick Cox
> Sent: 22 April 2005 15:32
> To: 'firstname.lastname@example.org'
> Subject: RE: Just another data reshaping problem
> Looks like
> gen id = 1
> reshape long group_ ID_g , i(id)
> and then a -contract-.
> There's really no substitute for detailed study
> of [R] reshape. The FAQ at
> may also help.
> Sascha Robert
> > Complex data reshaping unfortunately seems to lie beyond my logical
> > capabilities... so anyone up to a little brain-teaser?
> > My data (simplified) looks like this:
> > time group_1 ID_g1 group_2 ID_g2
> > 1 0 1 1 2
> > 1 0 1 1 3
> > 1 0 2 1 1
> > 1 1 1 0 1
> > 2...
> > and so on.
> > The data says something like (for the first row:) At time
> 1, ID 1 of
> > group 0 encountered ID 2 of group 2. Note that an encounter always
> > involves two entities of two different groups.
> > I would like to reshape the data to the form:
> > group ID num_encounters(*)
> > 0 1 x
> > 0 2 y
> > 1 1 z
> > ...
> > (*)sum of ALL dyadic encounters where ID participated
* For searches and help try: