[R] Calculating an index of colocation for a large dataset

Bree W bree.witteveen at alaska.edu
Sat Jun 22 00:18:57 CEST 2013

I have a complicated, multi-part question. My apologies if I do not make
myself clear. I am also a fairly novice R user, so forgive me if this seems
rudimentary. I want to calculate a index of colocation for whale dive data
and prey distribution data. This entails:

Calculating a frequency distribution of whale depth of dive data BY DIVE
into depth bins from prey (fish and zoop) data.
For each dive, calculate the center of gravity (CG) and inertia (I).
For each dive, calculate a global index of colocation (GIC) vs. each prey
I want to be able to write a function (or series of functions) such that I
do not have to separate my data by dive and rerun the functions for each
dive manually.

Example whale data, where number if the dive number (sometimes 40+ dives),
dive is equal to the depth and classification is related to the type of dive
it is. [IMG]http://i41.tinypic.com/33vc5rs.jpg[/IMG]

Depth bins come from a separate data set containing prey information:

I have the following codes that work for the dive data as a whole, but need
to write a loop or include an apply function such that I can run this for
the data for each dive which is contained in a single file. So, for a whale
with 40 dives, I need 40 whale frequencies, 40 whale CGs, 40 whale Is, etc.
The prey distributionss are the SAME for each dive! Ultimately, I'd like a
table which contains a list of the delta GIC values.

#bin whale dive depths
whale.cut=cut(whale,c(0 ,depths), right=FALSE) 

# compute CG 

# compute Inertia 

#compute GIC as per 
# compute delta CG

View this message in context: http://r.789695.n4.nabble.com/Calculating-an-index-of-colocation-for-a-large-dataset-tp4670084.html
Sent from the R help mailing list archive at Nabble.com.

More information about the R-help mailing list