R Under development (unstable) (2024-04-29 r86495 ucrt) -- "Unsuffered Consequences" Copyright (C) 2024 The R Foundation for Statistical Computing Platform: x86_64-w64-mingw32/x64 R is free software and comes with ABSOLUTELY NO WARRANTY. You are welcome to redistribute it under certain conditions. Type 'license()' or 'licence()' for distribution details. R is a collaborative project with many contributors. Type 'contributors()' for more information and 'citation()' on how to cite R or R packages in publications. Type 'demo()' for some demos, 'help()' for on-line help, or 'help.start()' for an HTML browser interface to help. Type 'q()' to quit R. > options("rgdal_show_exportToProj4_warnings"="none") > library(sp) > data(meuse) > # pick 10 rows > n = 10 > set.seed(1357) # fix seed for exact reproduction of test: > ran10 = sample(nrow(meuse), size = n, replace = FALSE) > meusedup = rbind(meuse, meuse[ran10, ]) > coordinates(meusedup) = c("x", "y") > zd = zerodist(meusedup) > sum(abs(sort(zd[,1]) - sort(ran10))) # 0! [1] 0 > zerodist(meusedup, unique.ID = TRUE) [1] 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 [19] 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 [37] 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 [55] 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 [73] 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 [91] 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 [109] 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 [127] 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 [145] 145 146 147 148 149 150 151 152 153 154 155 140 9 26 7 90 17 133 [163] 82 35 116 > # remove the duplicate rows: > meusedup2 = meusedup[-zd[,2], ] > print(summary(meusedup2)) Object of class SpatialPointsDataFrame Coordinates: min max x 178605 181390 y 329714 333611 Is projected: NA proj4string : [NA] Number of points: 155 Data attributes: cadmium copper lead zinc Min. : 0.200 Min. : 14.00 Min. : 37.0 Min. : 113.0 1st Qu.: 0.800 1st Qu.: 23.00 1st Qu.: 72.5 1st Qu.: 198.0 Median : 2.100 Median : 31.00 Median :123.0 Median : 326.0 Mean : 3.246 Mean : 40.32 Mean :153.4 Mean : 469.7 3rd Qu.: 3.850 3rd Qu.: 49.50 3rd Qu.:207.0 3rd Qu.: 674.5 Max. :18.100 Max. :128.00 Max. :654.0 Max. :1839.0 elev dist om ffreq soil lime Min. : 5.180 Min. :0.00000 Min. : 1.000 1:84 1:97 0:111 1st Qu.: 7.546 1st Qu.:0.07569 1st Qu.: 5.300 2:48 2:46 1: 44 Median : 8.180 Median :0.21184 Median : 6.900 3:23 3:12 Mean : 8.165 Mean :0.24002 Mean : 7.478 3rd Qu.: 8.955 3rd Qu.:0.36407 3rd Qu.: 9.000 Max. :10.520 Max. :0.88039 Max. :17.000 NA's :2 landuse dist.m W :50 Min. : 10.0 Ah :39 1st Qu.: 80.0 Am :22 Median : 270.0 Fw :10 Mean : 290.3 Ab : 8 3rd Qu.: 450.0 (Other):25 Max. :1000.0 NA's : 1 > meusedup3 <- subset(meusedup, !(1:nrow(meusedup) %in% zd[,2])) > print(summary(meusedup3)) Object of class SpatialPointsDataFrame Coordinates: min max x 178605 181390 y 329714 333611 Is projected: NA proj4string : [NA] Number of points: 155 Data attributes: cadmium copper lead zinc Min. : 0.200 Min. : 14.00 Min. : 37.0 Min. : 113.0 1st Qu.: 0.800 1st Qu.: 23.00 1st Qu.: 72.5 1st Qu.: 198.0 Median : 2.100 Median : 31.00 Median :123.0 Median : 326.0 Mean : 3.246 Mean : 40.32 Mean :153.4 Mean : 469.7 3rd Qu.: 3.850 3rd Qu.: 49.50 3rd Qu.:207.0 3rd Qu.: 674.5 Max. :18.100 Max. :128.00 Max. :654.0 Max. :1839.0 elev dist om ffreq soil lime Min. : 5.180 Min. :0.00000 Min. : 1.000 1:84 1:97 0:111 1st Qu.: 7.546 1st Qu.:0.07569 1st Qu.: 5.300 2:48 2:46 1: 44 Median : 8.180 Median :0.21184 Median : 6.900 3:23 3:12 Mean : 8.165 Mean :0.24002 Mean : 7.478 3rd Qu.: 8.955 3rd Qu.:0.36407 3rd Qu.: 9.000 Max. :10.520 Max. :0.88039 Max. :17.000 NA's :2 landuse dist.m W :50 Min. : 10.0 Ah :39 1st Qu.: 80.0 Am :22 Median : 270.0 Fw :10 Mean : 290.3 Ab : 8 3rd Qu.: 450.0 (Other):25 Max. :1000.0 NA's : 1 > dim(meuse) [1] 155 14 > dim(meusedup2) [1] 155 12 > dim(meusedup3) [1] 155 12 > dim(remove.duplicates(meusedup)) [1] 155 12 > > proc.time() user system elapsed 0.42 0.15 0.57