Calculate the murder rate per 100,000 for each state and store it in the ‘murder_rate’ object:

murder_rate <- (murders\(total / murders\)population) * 100000 print(murder_rate)

Compute the average murder rate for the US using the mean function:

us_avg_murder_rate <- mean(murder_rate, na.rm = TRUE) print(us_avg_murder_rate)

Find the state with the lowest murder rate using which.min

state_with_lowest_rate <- murders$state[which.min(murder_rate)] print(state_with_lowest_rate)

Create a variable ‘states’ containing the state names

states <- murders$state print(states)

Find the row with the smallest population using which.min

row_with_smallest_population <- which.min(murders$population) print(row_with_smallest_population)

Create two vectors, ‘temp’ and ‘city’

temp <- c(35, 88, 42, 84, 81, 30) city <- c(“Beijing”, “Lagos”, “Paris”, “Rio de Janeiro”, “San Juan”, “Toronto”) city_temps <- data.frame(name = city, temperature = temp) print(city_temps)

Load the ‘na_example’ data

data(“na_example”)

Use the is.na function to create a logical vector

ind <- is.na(na_example)

Use sum to count the number of NAs

num_of_nas <- sum(ind)

Create vectors for temperature in Fahrenheit and city names

temp_fahrenheit <- c(35, 88, 42, 84, 81, 30) city <- c(“Beijing”, “Lagos”, “Paris”, “Rio de Janeiro”, “San Juan”, “Toronto”)

Convert temperatures from Fahrenheit to Celsius

temp_celsius <- 59 * (temp_fahrenheit - 32) / 5

Create the data frame ‘city_temps’ with both Fahrenheit and Celsius temperatures

city_temps <- data.frame(name = city, temperature_fahrenheit = temp_fahrenheit, temperature_celsius = temp_celsius) print(city_temps)

Compute the murder rate per 100,000 for each state and store it in the ‘murder_rate’ object

murder_rate <- (murders\(total / murders\)population) * 100000

Compute the average murder rate for the US using the ‘mean’ function

us_avg_murder_rate <- mean(murder_rate, na.rm = TRUE)

Calculate the sum

sum_value <- sum(1/(1:1002)^2) print(sum_value)

Compare to the expected value π^2/6

expected_value <- pi^2/6 print(expected_value)

Compute the murder rate per 100,000 for each state and store it in the ‘murder_rate’ object

murder_rate <- (murders\(total / murders\)population) * 100000

Compute the average murder rate for the US using the ‘mean’ function

us_avg_murder_rate <- mean(murder_rate, na.rm = TRUE)