For this week’s optional practice problems, we have provided another dataset for you to use.
midwest
is a dataset that’s available in R as part of
the ggplot2
pacakge, similar to the
complete_old
dataset we have been using from the
ratdat
package. The midwest
dataset has
demographic information for counties from several Midwest states from
the 2000 U.S. Census.
?midwest
str
to learn more about data types in the
midwest
dataset. Of the primary vector types we discussed
in this week’s workshop (character, integer, numeric, logical), which
are represented in this dataset?Create a graph from the midwest
data that compares
population density between states. Follow the instructions below:
state
on the x-axis to popdensity
on the y-axis.geom_jitter
to create the scatter plot layer.
state
.shape =
). Shape is identified
using integers, and these are some of your point shape options:size =
).geom_boxplot
to create the boxplot layer.
fill
color.outlier.shape
to avoid double-plotting
outliers.theme_classic()
,
theme_bw()
)theme
function so
that:
The graph you create should look similar to the following graph:
Compute the following calculations on the midwest
dataset:
What is the maximum value of total population
(poptotal
)?
What is the minimum value of population density
(popdensity
)?
What are the quartiles (25%, 50%, 75%) for the percent of a
county’s population that is college educated (percollege
)?
The quantile
function will be helpful here.
What is the average number of adults per county
(popadults
)?
Create a sequence that runs from 8 to 85 at intervals of 7. Store
this sequence as an object called weird_seq
.
Create a sequence that runs from 1900 to 2025 at intervals of 5.
Store this sequence as an object called year_seq
.
Create a sequence that is runs from 12 to 22 and has a length of
47 (47 total items in the sequence). Store this sequence as an object
called seq_length
.
What was the most challenging aspect of this week’s workshop? Were you able to overcome it? If not, what assistance do you need to continue working through it?
What was the most rewarding aspect of this week’s workshop?