/usr/share/doc/r-cran-sp/tests/sp1.R is in r-cran-sp 1:1.0-15-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 | library(sp)
data(meuse)
x = meuse
nm <- names(meuse)
# rename to non-default names:
nm[1] <- "xcoord"
nm[2] <- "ycoord"
names(x) <- nm
# change column order
x = x[ , c(3:14,2,1)]
coordinates(x) <- c("xcoord", "ycoord") # columns named xcoord and ycoord
coordinates(x)[1:10,]
meuse[1:10,]
class(x)
sum = summary(x)
print(sum)
coordinates(x)
x <- as.data.frame(x)
class(x)
x[1:10, c("xcoord", "ycoord")]
x = meuse[1:4,]
coordinates(x) = c(1,2)
# row 1,2; cols 1:10
x[1:2,1:10]
# row 2, coord+col 9,10
x[2,9:10]
# coordinates, col 9+10
x[,9:10]
# coordinates + col 9:
x[,9]
# coordinates + zinc column:
x["zinc"]
# second row, coordinates + zinc
x[2,"zinc"]
# select; re-orders:
x[c("zinc","copper")]
# back as data.frame
as.data.frame(x)[1:3, c("zinc","copper","x", "y")]
|