(We stil use the US murders dataset, which should still be loaded in your R environment in RStudio.)
You can create a data frame using the data.frame
function. Here is
a quick example:
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)
Use the rank
function to determine the population rank of each state
from smallest population size to biggest. Save these ranks in an object
called ranks
, then create a data frame with the state name and its
rank. Call the data frame my_df
and its 2 column respectively state
and rank
.