Dear R-list,

I'm looking at association btw individuals. Below is an example of the dataset.
id = individual i
neighb1 = first individual associated with individual i
neighb2 = second individual associated with individual i
Etc
nb_assoc = total number of association at time t
date = date in POSIXct format
dT = time difference btw date(t) - date(t-1)  => always 4 seconds

id neighb1 neighb2 neighb3 neighb4 nb_assoc                date dT
LP0014  LP0016    <NA>    <NA>    <NA>        1 04/10/2011 00:05:03  4
LP0014  LP0016    <NA>    <NA>    <NA>        1 04/10/2011 00:05:07  4
LP0014  LP0016    <NA>    <NA>    <NA>        1 04/10/2011 00:05:11  4
LP0014  LP0016    <NA>    <NA>    <NA>        1 04/10/2011 00:05:15  4
LP0014  LP0016    <NA>    <NA>    <NA>        1 04/10/2011 00:05:19  4
LP0014  LP0016    <NA>    <NA>    <NA>        1 04/10/2011 00:05:23  4
LP0014  LP0016    <NA>    <NA>    <NA>        1 04/10/2011 00:05:27  4
LP0014  LP0016  LP0017    <NA>    <NA>        2 04/10/2011 00:05:31  4
LP0014  LP0016  LP0017    <NA>    <NA>        2 04/10/2011 00:05:35  4
LP0014  LP0016  LP0017    <NA>    <NA>        2 04/10/2011 00:05:39  4
LP0014  LP0016  LP0017    <NA>    <NA>        2 04/10/2011 00:05:43  4
LP0014  LP0016  LP0017    <NA>    <NA>        2 04/10/2011 00:05:47  4

I want to calculate the time an individual I spent with one, two or more other individuals.

I tried to calculate it separately for each association
result <- aggregate(data$dT ~ data$id+data$neighb1, FUN=sum)
result2 <- aggregate(data$dT ~ data$id+data$neighb2, FUN=sum)
Etc

And then merge result and result2 by "id" but it doesn't work.

In the end what I'd like is a table with:

Id / total time spent with neighb1 / total time spent with neighb1 and neighb2 / etc / total time spent in association (regardless who it was with)


Any suggestion/idea would be much appreciated!
Thanks.

Cheers,

Maud

Maud Berlincourt
Ph.D. Candidate
School of Life and Environmental Sciences
Deakin University
221 Burwood Highway
Burwood, Victoria 3125
Australia
E-Mail:   mberlinc@deakin.edu.au<mailto:mberlinc@deakin.edu.au>
Mobile:  (+61) 0412 864162



	[[alternative HTML version deleted]]

