Closed SarahBauduin closed 8 years ago
I did not see this issue before I pushed changes to the function. It now has both data.frame and data.table, with data.table working when there are >100 agents (that seems to be the cut point for speed). It is fast for lots of agents ... e.g., 100,000 or more. Changes are here: 449aa61a8607eb3d0ef4e0e9627234b6f818c66c
It passes all tests, so I believe it is equivalent, but perhaps it is not. Please make tests that would correctly test for the issue you point out here.
I added more tests and it works fine! It is super fast :)
Function in NetLogoR/R/patch-functions.R
I cannot figure out how to obtain the same results as when I merge the df by using a merge on data.tables. The second solution uses data.table but is wrong because if
torus = FALSE
, there isn'tnNeighbors
patches per agent so theid = rep(cellNum[,id], nNeighbors)
doesn't work. This solution also doesn't deal well with duplicate agents.