C Exercise 01

Last updated: 2024-07-28 11:47:09

C.1 Materials

The materials for this exercise are:

  • The R environment (Chapter 1)
  • Vectors (Chapter 2)

C.2 Question 1

  • On R start-up, several sample datasets are loaded
  • Two of them are:
    • state.name—Names of US states
    • state.area—Corresponding state area size, in \(mi^2\) (square miles)
  • Create a vector of state area sizes in \(km^2\)
  • Print a subset of state names for states whose areas are greater than 300,000 \(km^2\) and smaller than 700,000 \(km^2\)
  • Note: you need to convert from \(mi^2\) to \(km^2\)!
## [1] "California" "Montana"    "New Mexico" "Texas"

(50 points)

C.3 Question 2

  • Use the state.name and state.area vectors and write an expression that prints the name of the state which has the smallest area in the US
  • Note: do not use the specific values 39 or "Rhode Island" in your code!
## [1] "Rhode Island"

(50 points)