.GRP
was added to data.table
1.8.3, allowing you to do the following:
# Your data, as a data.frame
dat <- read.table(text='LAT LONG
13.5330 -15.4180
13.5330 -15.4180
13.5330 -15.4180
13.5330 -15.4180
13.5330 -15.4170
13.5330 -15.4170
13.5330 -15.4170
13.5340 -14.9350
13.5340 -14.9350
13.5340 -15.9170
13.3670 -14.6190', header=TRUE)
# Convert it to a data.table
# with keys as the combination of LAT and LONG
library(data.table)
DT <- data.table(dat, key="LAT,LONG")
DT[, Cluster_ID:=.GRP, by=key(DT)]
DT
# LAT LONG Cluster_ID
# 1: 13.367 -14.619 1
# 2: 13.533 -15.418 2
# 3: 13.533 -15.418 2
# 4: 13.533 -15.418 2
# 5: 13.533 -15.418 2
# 6: 13.533 -15.417 3
# 7: 13.533 -15.417 3
# 8: 13.533 -15.417 3
# 9: 13.534 -15.917 4
# 10: 13.534 -14.935 5
# 11: 13.534 -14.935 5