Debian Codegraph @

tests/zerodist.Rout.save

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