PredictiveEcology / NetLogoR

A translation of NetLogo functions, dictionary, and framework for R. Intended to be used with a discrete event simulator, like SpaDES
http://NetLogoR.PredictiveEcology.org
38 stars 4 forks source link

neighbors bug #5

Closed eliotmcintire closed 8 years ago

eliotmcintire commented 8 years ago

The part in the loop returns a list of length cellNum. The part in the vectorized code returns a list of length = length(unique(neighbors_df[,1])) ...

These should be the same, I suspect.

SarahBauduin commented 8 years ago

Yes, thanks! It was a problem when there were duplicates among the agents. I fixed both parts: the for-loop needed a unique() to not duplicate the neighbors in the list item for each duplicate, and I added an "id" in the vectorized part to have length(listAgents) == length(cellNum)