## Continuing example from `as_coords()`...
# \dontshow{
dm <-
c(5130.4659, 4932.7726, 4806.4339, 3853.3696, 0.0000, -3706.7044, -5306.2869, -2514.4093,
-007.6754, 1823.9137, -12246.7203, -7702.1145, 0.0000, -1217.3178, 7331.0370, -5731.1536)
names(dm) <-
rep(c("Nelson's Column", "Ostravice", "Tally Ho", "Washington Monument", "Null Island",
"Tristan da Cunha", "Mawson Peak", "Silvio Pettirossi International Airport"), 2)
invisible(as_coords(dm, fmt = 2))
latlon(dm) <- rep(c(TRUE, FALSE), each = 8)
# }
## Named "coords" object in degrees and minutes with
## eight values each of latitude and longitude
dm
## Extract the first eight values
dm[1:8]
## Exclude the first eight values
dm[-8:0]
## Index odd-numbered values
(index <- as.logical(1:16 %% 2))
dm[index]
## Extract values without names
unname(dm)[1:4]
## Create "coords" object with updated position of Tally Ho
newpos <- as_coords(c(4930.342, -12411.580), fmt = 2)
latlon(newpos) <- c(TRUE, FALSE)
newpos
## Update position using the "coords" object as replacement value
dm[c(3, 11)] <- newpos
dm[c(3, 11)]
## Or, as latlon didn't actually change, use simple numeric vector
dm[c(3, 11)] <- c(4930.342, -12411.580)
dm[c(3, 11)]
rm(dm, index, newpos)
Run the code above in your browser using DataLab