# Simplified example showing two clusters
s <- c(0,0,0,4,4)
ccheck <- c(1,1,1,2,2)
dat <- data.frame(x=1:5,y=0,
ti=s,
id=1:5)
res1 <- near_strings2(dat,'id','x','y','ti',2,1)
print(res1)
# \donttest{
# This runs faster than near_strings1
library(sp)
nyc_shoot$id <- 1:nrow(nyc_shoot) #incident ID can have dups
print(Sys.time())
res <- near_strings2(nyc_shoot@data,id='id',x='X_COORD_CD',y='Y_COORD_CD',
tim='OCCUR_DATE',DistThresh=1500,TimeThresh=3)
print(Sys.time()) #around 4 seconds on my machine
head(res)
# }
Run the code above in your browser using DataLab