Debian Codegraph @

tests/sp1.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
24 > nm <- names(meuse)
25 > # rename to non-default names:
26 > nm[1] <- "xcoord"
27 > nm[2] <- "ycoord"
28 > names(x) <- nm
29 > # change column order
30 > x = x[ , c(3:14,2,1)]
31 > coordinates(x) <- c("xcoord", "ycoord") # columns named xcoord and ycoord
32 > coordinates(x)[1:10,]
33 xcoord ycoord
34 1 181072 333611
35 2 181025 333558
36 3 181165 333537
37 4 181298 333484
38 5 181307 333330
39 6 181390 333260
40 7 181165 333370
41 8 181027 333363
42 9 181060 333231
43 10 181232 333168
44 > meuse[1:10,]
45 x y cadmium copper lead zinc elev dist om ffreq soil lime
46 1 181072 333611 11.7 85 299 1022 7.909 0.00135803 13.6 1 1 1
47 2 181025 333558 8.6 81 277 1141 6.983 0.01222430 14.0 1 1 1
48 3 181165 333537 6.5 68 199 640 7.800 0.10302900 13.0 1 1 1
49 4 181298 333484 2.6 81 116 257 7.655 0.19009400 8.0 1 2 0
50 5 181307 333330 2.8 48 117 269 7.480 0.27709000 8.7 1 2 0
51 6 181390 333260 3.0 61 137 281 7.791 0.36406700 7.8 1 2 0
52 7 181165 333370 3.2 31 132 346 8.217 0.19009400 9.2 1 2 0
53 8 181027 333363 2.8 29 150 406 8.490 0.09215160 9.5 1 1 0
54 9 181060 333231 2.4 37 133 347 8.668 0.18461400 10.6 1 1 0
55 10 181232 333168 1.6 24 80 183 9.049 0.30970200 6.3 1 2 0
56 landuse dist.m
57 1 Ah 50
58 2 Ah 30
59 3 Ah 150
60 4 Ga 270
61 5 Ah 380
62 6 Ga 470
63 7 Ah 240
64 8 Ab 120
65 9 Ab 240
66 10 W 420
67 > class(x)
68 [1] "SpatialPointsDataFrame"
69 attr(,"package")
70 [1] "sp"
71 > sum = summary(x)
72 > print(sum)
73 Object of class SpatialPointsDataFrame
74 Coordinates:
75 min max
76 xcoord 178605 181390
77 ycoord 329714 333611
78 Is projected: NA
79 proj4string : [NA]
80 Number of points: 155
81 Data attributes:
82 cadmium copper lead zinc
83 Min. : 0.200 Min. : 14.00 Min. : 37.0 Min. : 113.0
84 1st Qu.: 0.800 1st Qu.: 23.00 1st Qu.: 72.5 1st Qu.: 198.0
85 Median : 2.100 Median : 31.00 Median :123.0 Median : 326.0
86 Mean : 3.246 Mean : 40.32 Mean :153.4 Mean : 469.7
87 3rd Qu.: 3.850 3rd Qu.: 49.50 3rd Qu.:207.0 3rd Qu.: 674.5
88 Max. :18.100 Max. :128.00 Max. :654.0 Max. :1839.0
89
90 elev dist om ffreq soil lime
91 Min. : 5.180 Min. :0.00000 Min. : 1.000 1:84 1:97 0:111
92 1st Qu.: 7.546 1st Qu.:0.07569 1st Qu.: 5.300 2:48 2:46 1: 44
93 Median : 8.180 Median :0.21184 Median : 6.900 3:23 3:12
94 Mean : 8.165 Mean :0.24002 Mean : 7.478
95 3rd Qu.: 8.955 3rd Qu.:0.36407 3rd Qu.: 9.000
96 Max. :10.520 Max. :0.88039 Max. :17.000
97 NAs :2
98 landuse dist.m
99 W :50 Min. : 10.0
100 Ah :39 1st Qu.: 80.0
101 Am :22 Median : 270.0
102 Fw :10 Mean : 290.3
103 Ab : 8 3rd Qu.: 450.0
104 (Other):25 Max. :1000.0
105 NAs : 1
106 > coordinates(x)
107 xcoord ycoord
108 1 181072 333611
109 2 181025 333558
110 3 181165 333537
111 4 181298 333484
112 5 181307 333330
113 6 181390 333260
114 7 181165 333370
115 8 181027 333363
116 9 181060 333231
117 10 181232 333168
118 11 181191 333115
119 12 181032 333031
120 13 180874 333339
121 14 180969 333252
122 15 181011 333161
123 16 180830 333246
124 17 180763 333104
125 18 180694 332972
126 19 180625 332847
127 20 180555 332707
128 21 180642 332708
129 22 180704 332717
130 23 180704 332664
131 24 181153 332925
132 25 181147 332823
133 26 181167 332778
134 27 181008 332777
135 28 180973 332687
136 29 180916 332753
137 30 181352 332946
138 31 181133 332570
139 32 180878 332489
140 33 180829 332450
141 34 180954 332399
142 35 180956 332318
143 37 180710 332330
144 38 180632 332445
145 39 180530 332538
146 40 180478 332578
147 41 180383 332476
148 42 180494 332330
149 43 180561 332193
150 44 180451 332175
151 45 180410 332031
152 46 180355 332299
153 47 180292 332157
154 48 180283 332014
155 49 180282 331861
156 50 180270 331707
157 51 180199 331591
158 52 180135 331552
159 53 180237 332351
160 54 180103 332297
161 55 179973 332255
162 56 179826 332217
163 57 179687 332161
164 58 179792 332035
165 59 179902 332113
166 60 180100 332213
167 61 179604 332059
168 62 179526 331936
169 63 179495 331770
170 64 179489 331633
171 65 179414 331494
172 66 179334 331366
173 67 179255 331264
174 69 179470 331125
175 75 179692 330933
176 76 179852 330801
177 79 179140 330955
178 80 179128 330867
179 81 179065 330864
180 82 179007 330727
181 83 179110 330758
182 84 179032 330645
183 85 179095 330636
184 86 179058 330510
185 87 178810 330666
186 88 178912 330779
187 89 178981 330924
188 90 179076 331005
189 123 180151 330353
190 160 179211 331175
191 163 181118 333214
192 70 179474 331304
193 71 179559 331423
194 91 179022 330873
195 92 178953 330742
196 93 178875 330516
197 94 178803 330349
198 95 179029 330394
199 96 178605 330406
200 97 178701 330557
201 98 179547 330245
202 99 179301 330179
203 100 179405 330567
204 101 179462 330766
205 102 179293 330797
206 103 179180 330710
207 104 179206 330398
208 105 179618 330458
209 106 179782 330540
210 108 179980 330773
211 109 180067 331185
212 110 180162 331387
213 111 180451 331473
214 112 180328 331158
215 113 180276 330963
216 114 180114 330803
217 115 179881 330912
218 116 179774 330921
219 117 179657 331150
220 118 179731 331245
221 119 179717 331441
222 120 179446 331422
223 121 179524 331565
224 122 179644 331730
225 124 180321 330366
226 125 180162 331837
227 126 180029 331720
228 127 179797 331919
229 128 179642 331955
230 129 179849 332142
231 130 180265 332297
232 131 180107 332101
233 132 180462 331947
234 133 180478 331822
235 134 180347 331700
236 135 180862 333116
237 136 180700 332882
238 161 180201 331160
239 162 180173 331923
240 137 180923 332874
241 138 180467 331694
242 140 179917 331325
243 141 179822 331242
244 142 179991 331069
245 143 179120 330578
246 144 179034 330561
247 145 179085 330433
248 146 179236 330046
249 147 179456 330072
250 148 179550 329940
251 149 179445 329807
252 150 179337 329870
253 151 179245 329714
254 152 179024 329733
255 153 178786 329822
256 154 179135 329890
257 155 179030 330082
258 156 179184 330182
259 157 179085 330292
260 158 178875 330311
261 159 179466 330381
262 164 180627 330190
263 >
264 > x <- as.data.frame(x)
265 > class(x)
266 [1] "data.frame"
267 >
268 > x[1:10, c("xcoord", "ycoord")]
269 xcoord ycoord
270 1 181072 333611
271 2 181025 333558
272 3 181165 333537
273 4 181298 333484
274 5 181307 333330
275 6 181390 333260
276 7 181165 333370
277 8 181027 333363
278 9 181060 333231
279 10 181232 333168
280 >
281 > x = meuse[1:4,]
282 > coordinates(x) = c(1,2)
283 > # row 1,2; cols 1:10
284 > x[1:2,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 lime
289 1 1
290 2 1
291 > # row 2, coord+col 9,10
292 > x[2,9:10]
293 coordinates soil lime
294 2 (181025, 333558) 1 1
295 > # coordinates, col 9+10
296 > x[,9:10]
297 coordinates soil lime
298 1 (181072, 333611) 1 1
299 2 (181025, 333558) 1 1
300 3 (181165, 333537) 1 1
301 4 (181298, 333484) 2 0
302 > # coordinates + col 9:
303 > x[,9]
304 coordinates soil
305 1 (181072, 333611) 1
306 2 (181025, 333558) 1
307 3 (181165, 333537) 1
308 4 (181298, 333484) 2
309 > # coordinates + zinc column:
310 > x["zinc"]
311 coordinates zinc
312 1 (181072, 333611) 1022
313 2 (181025, 333558) 1141
314 3 (181165, 333537) 640
315 4 (181298, 333484) 257
316 > # second row, coordinates + zinc
317 > x[2,"zinc"]
318 coordinates zinc
319 2 (181025, 333558) 1141
320 > # select; re-orders:
321 > x[c("zinc","copper")]
322 coordinates zinc copper
323 1 (181072, 333611) 1022 85
324 2 (181025, 333558) 1141 81
325 3 (181165, 333537) 640 68
326 4 (181298, 333484) 257 81
327 > # back as data.frame
328 > as.data.frame(x)[1:3, c("zinc","copper","x", "y")]
329 zinc copper x y
330 1 1022 85 181072 333611
331 2 1141 81 181025 333558
332 3 640 68 181165 333537
333 >
334 > proc.time()
335 user system elapsed
336 0.263 0.037 0.291