################################################## ## HOMEWORK 2 ## Intro to R Part 2: Packages and Functions ## ## Type your answer below each prompt. ################################################## ## Q1. Load the `maps` package into memory. ## Q2. The maps package comes with a dataset called `world.cities`. What kind of object is 'world.cities'? ## Q3. How many rows and columns does `world.cities` have? ## Q4. What is the original data source of world.cities? ## Hint: datasets have help pages too! ## Q5. What is the average population of the world cities? ## Q6. How many world cities have a population larger than 500,000? ## Q7. The maps package also has a dataset called `us.cities`, which includes columns ## for longitude and latitude. Make a scatter plot of the longitude and latitude coordinates. ## Q8. Import the following CSV file as a data frame:
https://raw.githubusercontent.com/ajlyons/rspatial_bgs23/main/notebooks/data/sf_libraries.csv ## How many libraries are there in San Francisco? ## Q09. Use `runif()` to generate 20 random numbers uniformly distributed between 100 and 200. ## Q10. Rewrite the following expression with pipes. You can use either the ## traditional pipe (`%>%`) from the magrittr package, or the more recent native ## pipe (`|>`) sum(round(rnorm(n = 200, mean = 50, sd = 5)))