maps
package into memory.library(maps)
world.cities
. What kind of object is ‘world.cities’?class(world.cities)
## [1] "data.frame"
world.cities
have?dim(world.cities)
## [1] 43645 6
Or:
nrow(world.cities)
## [1] 43645
ncol(world.cities)
## [1] 6
?world.cities
“The data were originally obtained from Stefan Helders’ website (http://www.world-gazetteer.com), which now redirects to http://www.populationmondiale.com.”
mean(world.cities$pop)
## [1] 57822.31
sum(world.cities$pop >= 1000000)
## [1] 313
us.cities
, which includes columns for longitude and
latitude.Make a scatter plot of the longitude and latitude ## coordinates.
plot(us.cities$long, us.cities$lat, pch = 16, asp = 1, cex = 0.5)
libraries <- read.csv("https://raw.githubusercontent.com/ajlyons/rspatial_bgs23/main/notebooks/data/sf_libraries.csv")
nrow(libraries)
## [1] 28
runif()
to generate 20 random numbers
uniformly distributed between 100 and 200.runif(20, min = 100, max = 200)
## [1] 159.0500 139.6720 106.6303 192.1696 151.9047 195.9522 191.5418 129.5753
## [9] 196.5169 129.3571 155.2220 127.4217 144.6266 149.8893 119.4761 174.9597
## [17] 144.2200 168.2474 162.9821 174.2144
%>%
) from the magrittr package, or
the more recent native pipe (|>
).sum(round(rnorm(n = 200, mean = 50, sd = 5)))
rnorm(n = 200, mean = 50, sd = 5) |> round() |> sum()
## [1] 9981
or
library(magrittr)
rnorm(n = 200, mean = 50, sd = 5) %>% round() %>% sum()
## [1] 10023