Debian Codegraph @

tests/base.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 > x = meuse[1:10, ] # limit the output
24 > coordinates(x) = c("x", "y") # names
25 > bbox(x)
26 min max
27 x 181025 181390
28 y 333168 333611
29 > is.projected(x)
30 [1] NA
31 > dimensions(x)
32 [1] 2
33 > x
34 coordinates cadmium copper lead zinc elev dist om ffreq soil
35 1 (181072, 333611) 11.7 85 299 1022 7.909 0.00135803 13.6 1 1
36 2 (181025, 333558) 8.6 81 277 1141 6.983 0.01222430 14.0 1 1
37 3 (181165, 333537) 6.5 68 199 640 7.800 0.10302900 13.0 1 1
38 4 (181298, 333484) 2.6 81 116 257 7.655 0.19009400 8.0 1 2
39 5 (181307, 333330) 2.8 48 117 269 7.480 0.27709000 8.7 1 2
40 6 (181390, 333260) 3.0 61 137 281 7.791 0.36406700 7.8 1 2
41 7 (181165, 333370) 3.2 31 132 346 8.217 0.19009400 9.2 1 2
42 8 (181027, 333363) 2.8 29 150 406 8.490 0.09215160 9.5 1 1
43 9 (181060, 333231) 2.4 37 133 347 8.668 0.18461400 10.6 1 1
44 10 (181232, 333168) 1.6 24 80 183 9.049 0.30970200 6.3 1 2
45 lime landuse dist.m
46 1 1 Ah 50
47 2 1 Ah 30
48 3 1 Ah 150
49 4 0 Ga 270
50 5 0 Ah 380
51 6 0 Ga 470
52 7 0 Ah 240
53 8 0 Ab 120
54 9 0 Ab 240
55 10 0 W 420
56 >
57 > x = meuse[1:10, ]
58 > coordinates(x) = c(1, 2) # coordinate column numbers
59 > x
60 coordinates cadmium copper lead zinc elev dist om ffreq soil
61 1 (181072, 333611) 11.7 85 299 1022 7.909 0.00135803 13.6 1 1
62 2 (181025, 333558) 8.6 81 277 1141 6.983 0.01222430 14.0 1 1
63 3 (181165, 333537) 6.5 68 199 640 7.800 0.10302900 13.0 1 1
64 4 (181298, 333484) 2.6 81 116 257 7.655 0.19009400 8.0 1 2
65 5 (181307, 333330) 2.8 48 117 269 7.480 0.27709000 8.7 1 2
66 6 (181390, 333260) 3.0 61 137 281 7.791 0.36406700 7.8 1 2
67 7 (181165, 333370) 3.2 31 132 346 8.217 0.19009400 9.2 1 2
68 8 (181027, 333363) 2.8 29 150 406 8.490 0.09215160 9.5 1 1
69 9 (181060, 333231) 2.4 37 133 347 8.668 0.18461400 10.6 1 1
70 10 (181232, 333168) 1.6 24 80 183 9.049 0.30970200 6.3 1 2
71 lime landuse dist.m
72 1 1 Ah 50
73 2 1 Ah 30
74 3 1 Ah 150
75 4 0 Ga 270
76 5 0 Ah 380
77 6 0 Ga 470
78 7 0 Ah 240
79 8 0 Ab 120
80 9 0 Ab 240
81 10 0 W 420
82 >
83 > x = meuse[1:10, ]
84 > coordinates(x) = ~x+y # coordinates formula
85 > x
86 coordinates cadmium copper lead zinc elev dist om ffreq soil
87 1 (181072, 333611) 11.7 85 299 1022 7.909 0.00135803 13.6 1 1
88 2 (181025, 333558) 8.6 81 277 1141 6.983 0.01222430 14.0 1 1
89 3 (181165, 333537) 6.5 68 199 640 7.800 0.10302900 13.0 1 1
90 4 (181298, 333484) 2.6 81 116 257 7.655 0.19009400 8.0 1 2
91 5 (181307, 333330) 2.8 48 117 269 7.480 0.27709000 8.7 1 2
92 6 (181390, 333260) 3.0 61 137 281 7.791 0.36406700 7.8 1 2
93 7 (181165, 333370) 3.2 31 132 346 8.217 0.19009400 9.2 1 2
94 8 (181027, 333363) 2.8 29 150 406 8.490 0.09215160 9.5 1 1
95 9 (181060, 333231) 2.4 37 133 347 8.668 0.18461400 10.6 1 1
96 10 (181232, 333168) 1.6 24 80 183 9.049 0.30970200 6.3 1 2
97 lime landuse dist.m
98 1 1 Ah 50
99 2 1 Ah 30
100 3 1 Ah 150
101 4 0 Ga 270
102 5 0 Ah 380
103 6 0 Ga 470
104 7 0 Ah 240
105 8 0 Ab 120
106 9 0 Ab 240
107 10 0 W 420
108 >
109 > x = meuse[1:10, ]
110 > coordinates(x) = meuse[1:10, c("x", "y")] # coords, as data.frame
111 > x
112 coordinates x y cadmium copper lead zinc elev dist
113 1 (181072, 333611) 181072 333611 11.7 85 299 1022 7.909 0.00135803
114 2 (181025, 333558) 181025 333558 8.6 81 277 1141 6.983 0.01222430
115 3 (181165, 333537) 181165 333537 6.5 68 199 640 7.800 0.10302900
116 4 (181298, 333484) 181298 333484 2.6 81 116 257 7.655 0.19009400
117 5 (181307, 333330) 181307 333330 2.8 48 117 269 7.480 0.27709000
118 6 (181390, 333260) 181390 333260 3.0 61 137 281 7.791 0.36406700
119 7 (181165, 333370) 181165 333370 3.2 31 132 346 8.217 0.19009400
120 8 (181027, 333363) 181027 333363 2.8 29 150 406 8.490 0.09215160
121 9 (181060, 333231) 181060 333231 2.4 37 133 347 8.668 0.18461400
122 10 (181232, 333168) 181232 333168 1.6 24 80 183 9.049 0.30970200
123 om ffreq soil lime landuse dist.m
124 1 13.6 1 1 1 Ah 50
125 2 14.0 1 1 1 Ah 30
126 3 13.0 1 1 1 Ah 150
127 4 8.0 1 2 0 Ga 270
128 5 8.7 1 2 0 Ah 380
129 6 7.8 1 2 0 Ga 470
130 7 9.2 1 2 0 Ah 240
131 8 9.5 1 1 0 Ab 120
132 9 10.6 1 1 0 Ab 240
133 10 6.3 1 2 0 W 420
134 >
135 > x = meuse[1:10, ]
136 > coordinates(x) = as.matrix(meuse[1:10, c("x", "y")]) # coords, as matrix
137 > x
138 coordinates x y cadmium copper lead zinc elev dist
139 1 (181072, 333611) 181072 333611 11.7 85 299 1022 7.909 0.00135803
140 2 (181025, 333558) 181025 333558 8.6 81 277 1141 6.983 0.01222430
141 3 (181165, 333537) 181165 333537 6.5 68 199 640 7.800 0.10302900
142 4 (181298, 333484) 181298 333484 2.6 81 116 257 7.655 0.19009400
143 5 (181307, 333330) 181307 333330 2.8 48 117 269 7.480 0.27709000
144 6 (181390, 333260) 181390 333260 3.0 61 137 281 7.791 0.36406700
145 7 (181165, 333370) 181165 333370 3.2 31 132 346 8.217 0.19009400
146 8 (181027, 333363) 181027 333363 2.8 29 150 406 8.490 0.09215160
147 9 (181060, 333231) 181060 333231 2.4 37 133 347 8.668 0.18461400
148 10 (181232, 333168) 181232 333168 1.6 24 80 183 9.049 0.30970200
149 om ffreq soil lime landuse dist.m
150 1 13.6 1 1 1 Ah 50
151 2 14.0 1 1 1 Ah 30
152 3 13.0 1 1 1 Ah 150
153 4 8.0 1 2 0 Ga 270
154 5 8.7 1 2 0 Ah 380
155 6 7.8 1 2 0 Ga 470
156 7 9.2 1 2 0 Ah 240
157 8 9.5 1 1 0 Ab 120
158 9 10.6 1 1 0 Ab 240
159 10 6.3 1 2 0 W 420
160 >
161 > x = meuse[1:20,]
162 > coordinates(x) = c("x", "y") # coordinate column names
163 > print(summary(x))
164 Object of class SpatialPointsDataFrame
165 Coordinates:
166 min max
167 x 180555 181390
168 y 332707 333611
169 Is projected: NA
170 proj4string : [NA]
171 Number of points: 20
172 Data attributes:
173 cadmium copper lead zinc
174 Min. : 1.400 Min. :24.00 Min. : 80.0 Min. : 183.0
175 1st Qu.: 2.475 1st Qu.:30.50 1st Qu.:126.8 1st Qu.: 278.0
176 Median : 3.100 Median :64.50 Median :142.5 Median : 455.0
177 Mean : 5.465 Mean :56.95 Mean :171.7 Mean : 569.7
178 3rd Qu.: 8.625 3rd Qu.:81.00 3rd Qu.:215.2 3rd Qu.: 806.8
179 Max. :12.900 Max. :95.00 Max. :299.0 Max. :1141.0
180
181 elev dist om ffreq soil lime
182 Min. :6.860 Min. :0.000000 Min. : 6.300 1:20 1:14 0:11
183 1st Qu.:7.280 1st Qu.:0.009508 1st Qu.: 8.625 2: 0 2: 6 1: 9
184 Median :7.795 Median :0.108480 Median :10.050 3: 0 3: 0
185 Mean :7.952 Mean :0.128719 Mean :11.285
186 3rd Qu.:8.705 3rd Qu.:0.199601 3rd Qu.:14.200
187 Max. :9.073 Max. :0.364067 Max. :16.200
188
189 landuse dist.m
190 Ah :7 Min. : 10.0
191 W :6 1st Qu.: 17.5
192 Ab :2 Median :140.0
193 Ga :2 Mean :174.5
194 Ag :1 3rd Qu.:277.5
195 (Other):1 Max. :470.0
196 NAs :1
197 >
198 > x[1:10] # first 10 columns
199 coordinates cadmium copper lead zinc elev dist om ffreq soil
200 1 (181072, 333611) 11.7 85 299 1022 7.909 0.00135803 13.6 1 1
201 2 (181025, 333558) 8.6 81 277 1141 6.983 0.01222430 14.0 1 1
202 3 (181165, 333537) 6.5 68 199 640 7.800 0.10302900 13.0 1 1
203 4 (181298, 333484) 2.6 81 116 257 7.655 0.19009400 8.0 1 2
204 5 (181307, 333330) 2.8 48 117 269 7.480 0.27709000 8.7 1 2
205 6 (181390, 333260) 3.0 61 137 281 7.791 0.36406700 7.8 1 2
206 7 (181165, 333370) 3.2 31 132 346 8.217 0.19009400 9.2 1 2
207 8 (181027, 333363) 2.8 29 150 406 8.490 0.09215160 9.5 1 1
208 9 (181060, 333231) 2.4 37 133 347 8.668 0.18461400 10.6 1 1
209 10 (181232, 333168) 1.6 24 80 183 9.049 0.30970200 6.3 1 2
210 11 (181191, 333115) 1.4 25 86 189 9.015 0.31511600 6.4 1 2
211 12 (181032, 333031) 1.8 25 97 251 9.073 0.22812300 9.0 1 1
212 13 (180874, 333339) 11.2 93 285 1096 7.320 0.00000000 15.4 1 1
213 14 (180969, 333252) 2.5 31 183 504 8.815 0.11393200 8.4 1 1
214 15 (181011, 333161) 2.0 27 130 326 8.937 0.16833600 9.1 1 1
215 16 (180830, 333246) 9.5 86 240 1032 7.702 0.00000000 16.2 1 1
216 17 (180763, 333104) 7.0 74 133 606 7.160 0.01222430 16.0 1 1
217 18 (180694, 332972) 7.1 69 148 711 7.100 0.01222430 16.0 1 1
218 19 (180625, 332847) 8.7 69 207 735 7.020 0.00000000 13.7 1 1
219 20 (180555, 332707) 12.9 95 284 1052 6.860 0.00000000 14.8 1 1
220 lime
221 1 1
222 2 1
223 3 1
224 4 0
225 5 0
226 6 0
227 7 0
228 8 0
229 9 0
230 10 0
231 11 0
232 12 0
233 13 1
234 14 0
235 15 0
236 16 1
237 17 1
238 18 1
239 19 1
240 20 1
241 > x[, 1:10] # first 10 columns
242 coordinates cadmium copper lead zinc elev dist om ffreq soil
243 1 (181072, 333611) 11.7 85 299 1022 7.909 0.00135803 13.6 1 1
244 2 (181025, 333558) 8.6 81 277 1141 6.983 0.01222430 14.0 1 1
245 3 (181165, 333537) 6.5 68 199 640 7.800 0.10302900 13.0 1 1
246 4 (181298, 333484) 2.6 81 116 257 7.655 0.19009400 8.0 1 2
247 5 (181307, 333330) 2.8 48 117 269 7.480 0.27709000 8.7 1 2
248 6 (181390, 333260) 3.0 61 137 281 7.791 0.36406700 7.8 1 2
249 7 (181165, 333370) 3.2 31 132 346 8.217 0.19009400 9.2 1 2
250 8 (181027, 333363) 2.8 29 150 406 8.490 0.09215160 9.5 1 1
251 9 (181060, 333231) 2.4 37 133 347 8.668 0.18461400 10.6 1 1
252 10 (181232, 333168) 1.6 24 80 183 9.049 0.30970200 6.3 1 2
253 11 (181191, 333115) 1.4 25 86 189 9.015 0.31511600 6.4 1 2
254 12 (181032, 333031) 1.8 25 97 251 9.073 0.22812300 9.0 1 1
255 13 (180874, 333339) 11.2 93 285 1096 7.320 0.00000000 15.4 1 1
256 14 (180969, 333252) 2.5 31 183 504 8.815 0.11393200 8.4 1 1
257 15 (181011, 333161) 2.0 27 130 326 8.937 0.16833600 9.1 1 1
258 16 (180830, 333246) 9.5 86 240 1032 7.702 0.00000000 16.2 1 1
259 17 (180763, 333104) 7.0 74 133 606 7.160 0.01222430 16.0 1 1
260 18 (180694, 332972) 7.1 69 148 711 7.100 0.01222430 16.0 1 1
261 19 (180625, 332847) 8.7 69 207 735 7.020 0.00000000 13.7 1 1
262 20 (180555, 332707) 12.9 95 284 1052 6.860 0.00000000 14.8 1 1
263 lime
264 1 1
265 2 1
266 3 1
267 4 0
268 5 0
269 6 0
270 7 0
271 8 0
272 9 0
273 10 0
274 11 0
275 12 0
276 13 1
277 14 0
278 15 0
279 16 1
280 17 1
281 18 1
282 19 1
283 20 1
284 > x[1:10,] # rows 1-10
285 coordinates cadmium copper lead zinc elev dist om ffreq soil
286 1 (181072, 333611) 11.7 85 299 1022 7.909 0.00135803 13.6 1 1
287 2 (181025, 333558) 8.6 81 277 1141 6.983 0.01222430 14.0 1 1
288 3 (181165, 333537) 6.5 68 199 640 7.800 0.10302900 13.0 1 1
289 4 (181298, 333484) 2.6 81 116 257 7.655 0.19009400 8.0 1 2
290 5 (181307, 333330) 2.8 48 117 269 7.480 0.27709000 8.7 1 2
291 6 (181390, 333260) 3.0 61 137 281 7.791 0.36406700 7.8 1 2
292 7 (181165, 333370) 3.2 31 132 346 8.217 0.19009400 9.2 1 2
293 8 (181027, 333363) 2.8 29 150 406 8.490 0.09215160 9.5 1 1
294 9 (181060, 333231) 2.4 37 133 347 8.668 0.18461400 10.6 1 1
295 10 (181232, 333168) 1.6 24 80 183 9.049 0.30970200 6.3 1 2
296 lime landuse dist.m
297 1 1 Ah 50
298 2 1 Ah 30
299 3 1 Ah 150
300 4 0 Ga 270
301 5 0 Ah 380
302 6 0 Ga 470
303 7 0 Ah 240
304 8 0 Ab 120
305 9 0 Ab 240
306 10 0 W 420
307 > x["zinc"] # column zinc + coords
308 coordinates zinc
309 1 (181072, 333611) 1022
310 2 (181025, 333558) 1141
311 3 (181165, 333537) 640
312 4 (181298, 333484) 257
313 5 (181307, 333330) 269
314 6 (181390, 333260) 281
315 7 (181165, 333370) 346
316 8 (181027, 333363) 406
317 9 (181060, 333231) 347
318 10 (181232, 333168) 183
319 11 (181191, 333115) 189
320 12 (181032, 333031) 251
321 13 (180874, 333339) 1096
322 14 (180969, 333252) 504
323 15 (181011, 333161) 326
324 16 (180830, 333246) 1032
325 17 (180763, 333104) 606
326 18 (180694, 332972) 711
327 19 (180625, 332847) 735
328 20 (180555, 332707) 1052
329 > x[, "zinc"] # idem
330 coordinates zinc
331 1 (181072, 333611) 1022
332 2 (181025, 333558) 1141
333 3 (181165, 333537) 640
334 4 (181298, 333484) 257
335 5 (181307, 333330) 269
336 6 (181390, 333260) 281
337 7 (181165, 333370) 346
338 8 (181027, 333363) 406
339 9 (181060, 333231) 347
340 10 (181232, 333168) 183
341 11 (181191, 333115) 189
342 12 (181032, 333031) 251
343 13 (180874, 333339) 1096
344 14 (180969, 333252) 504
345 15 (181011, 333161) 326
346 16 (180830, 333246) 1032
347 17 (180763, 333104) 606
348 18 (180694, 332972) 711
349 19 (180625, 332847) 735
350 20 (180555, 332707) 1052
351 > x[1:10, "zinc"] # idem
352 coordinates zinc
353 1 (181072, 333611) 1022
354 2 (181025, 333558) 1141
355 3 (181165, 333537) 640
356 4 (181298, 333484) 257
357 5 (181307, 333330) 269
358 6 (181390, 333260) 281
359 7 (181165, 333370) 346
360 8 (181027, 333363) 406
361 9 (181060, 333231) 347
362 10 (181232, 333168) 183
363 > x[1:10, c("zinc", "cadmium")] # idem
364 coordinates zinc cadmium
365 1 (181072, 333611) 1022 11.7
366 2 (181025, 333558) 1141 8.6
367 3 (181165, 333537) 640 6.5
368 4 (181298, 333484) 257 2.6
369 5 (181307, 333330) 269 2.8
370 6 (181390, 333260) 281 3.0
371 7 (181165, 333370) 346 3.2
372 8 (181027, 333363) 406 2.8
373 9 (181060, 333231) 347 2.4
374 10 (181232, 333168) 183 1.6
375 > x[["zinc"]]
376 [1] 1022 1141 640 257 269 281 346 406 347 183 189 251 1096 504 326
377 [16] 1032 606 711 735 1052
378 > x[["lnzinc"]] <- log(x[["zinc"]])
379 > x
380 coordinates cadmium copper lead zinc elev dist om ffreq soil
381 1 (181072, 333611) 11.7 85 299 1022 7.909 0.00135803 13.6 1 1
382 2 (181025, 333558) 8.6 81 277 1141 6.983 0.01222430 14.0 1 1
383 3 (181165, 333537) 6.5 68 199 640 7.800 0.10302900 13.0 1 1
384 4 (181298, 333484) 2.6 81 116 257 7.655 0.19009400 8.0 1 2
385 5 (181307, 333330) 2.8 48 117 269 7.480 0.27709000 8.7 1 2
386 6 (181390, 333260) 3.0 61 137 281 7.791 0.36406700 7.8 1 2
387 7 (181165, 333370) 3.2 31 132 346 8.217 0.19009400 9.2 1 2
388 8 (181027, 333363) 2.8 29 150 406 8.490 0.09215160 9.5 1 1
389 9 (181060, 333231) 2.4 37 133 347 8.668 0.18461400 10.6 1 1
390 10 (181232, 333168) 1.6 24 80 183 9.049 0.30970200 6.3 1 2
391 11 (181191, 333115) 1.4 25 86 189 9.015 0.31511600 6.4 1 2
392 12 (181032, 333031) 1.8 25 97 251 9.073 0.22812300 9.0 1 1
393 13 (180874, 333339) 11.2 93 285 1096 7.320 0.00000000 15.4 1 1
394 14 (180969, 333252) 2.5 31 183 504 8.815 0.11393200 8.4 1 1
395 15 (181011, 333161) 2.0 27 130 326 8.937 0.16833600 9.1 1 1
396 16 (180830, 333246) 9.5 86 240 1032 7.702 0.00000000 16.2 1 1
397 17 (180763, 333104) 7.0 74 133 606 7.160 0.01222430 16.0 1 1
398 18 (180694, 332972) 7.1 69 148 711 7.100 0.01222430 16.0 1 1
399 19 (180625, 332847) 8.7 69 207 735 7.020 0.00000000 13.7 1 1
400 20 (180555, 332707) 12.9 95 284 1052 6.860 0.00000000 14.8 1 1
401 lime landuse dist.m lnzinc
402 1 1 Ah 50 6.929517
403 2 1 Ah 30 7.039660
404 3 1 Ah 150 6.461468
405 4 0 Ga 270 5.549076
406 5 0 Ah 380 5.594711
407 6 0 Ga 470 5.638355
408 7 0 Ah 240 5.846439
409 8 0 Ab 120 6.006353
410 9 0 Ab 240 5.849325
411 10 0 W 420 5.209486
412 11 0 Fh 400 5.241747
413 12 0 Ag 300 5.525453
414 13 1 W 20 6.999422
415 14 0 Ah 130 6.222576
416 15 0 Ah 220 5.786897
417 16 1 W 10 6.939254
418 17 1 W 10 6.406880
419 18 1 W 10 6.566672
420 19 1 W 10 6.599870
421 20 1 <NA> 10 6.958448
422 >
423 > print(summary(x[1:10, "zinc"])) # check bbox
424 Object of class SpatialPointsDataFrame
425 Coordinates:
426 min max
427 x 181025 181390
428 y 333168 333611
429 Is projected: NA
430 proj4string : [NA]
431 Number of points: 10
432 Data attributes:
433 zinc
434 Min. : 183.0
435 1st Qu.: 272.0
436 Median : 346.5
437 Mean : 489.2
438 3rd Qu.: 581.5
439 Max. :1141.0
440 > print(summary(x["zinc"])) # compare bbox
441 Object of class SpatialPointsDataFrame
442 Coordinates:
443 min max
444 x 180555 181390
445 y 332707 333611
446 Is projected: NA
447 proj4string : [NA]
448 Number of points: 20
449 Data attributes:
450 zinc
451 Min. : 183.0
452 1st Qu.: 278.0
453 Median : 455.0
454 Mean : 569.7
455 3rd Qu.: 806.8
456 Max. :1141.0
457 >
458 > data(meuse.grid)
459 > coordinates(meuse.grid) = ~x+y
460 > gridded(meuse.grid) = TRUE
461 > plot(meuse.grid)
462 >
463 > proc.time()
464 user system elapsed
465 0.322 0.052 0.365