library (mosaic)
library (tidyverse)
The state of Arizona records the number of automobile deaths two years ago in each of the state’s 14 counties:
Using R, enter these data into a variable called
autodths.
autodths = c (30, 15, 183, 9, 7, 39, 28, 30, 76, 13, 21, 18, 323, 3)
What is the mean number of deaths per county?
mean (autodths)
## [1] 56.78571
What is the median number of deaths per county?
median (autodths)
## [1] 24.5
barplot (autodths)
barplot (autodths, main= “Auto Deaths by County”)
barplot (autodths, main= “Auto Deaths by County”,horiz=FALSE)
barplot (autodths, main= "Auto Deaths by County", names.arg = c ("Apache", "Cochise", "Coconino", "Gila", "Graham", "Greenlee", "La Paz", "Maricopa", "Mohave", "Navajo", "Pima", "Pinal", "Santa Cruz", "Yavapai"), col = 'purple', cex.names = .5, cex.axis = .75)
In a survey of students several years ago, one question asked for each student’s political preference (Democrat (D), Independent (I), or Republican (R)). Here are the 14 responses:
Using R, enter these data into a variable called
polpref.
polpref = c("D", "I", "I", "D", "I", "D", "I", "I", "I", "D", "I", "R", "D", "D")
Use the tally() function to determine the most popular
choice of political preference.
tally (polpref)
## X
## D I R
## 6 7 1
The most popular choice of political preference is independent
table (polpref)
## polpref
## D I R
## 6 7 1
counts <-table (polpref)
barplot(counts)
barplot(counts, main = "Student Political Preference", horiz = TRUE)
barplot(counts, main = "Student Political Preference", horiz = TRUE, names.arg = c("Democrat", "Independent", "Republican"))
barplot(counts, main = "Student Political Preference", horiz = TRUE, names.arg = c("Democrat", "Independent", "Republican"), col = 'pink')
barplot(counts, main = "Student Political Preference", horiz = TRUE, names.arg = c("Democrat", "Independent", "Republican"), col = 'pink', cex.names = .75)
Create a Canva Presentation with two slides:
Homework 1 data-external=“1” by Danielle Maestas `
Trouble embedding? No worries! Provide your Canva link here as a back-up
URL Link to Canva Site: [Your Name - Homework 1]*https://www.canva.com/design/DAGKIivr8Zk/trztjQ_kdUHqEGBW7BSGiQ/view?utm_content=DAGKIivr8Zk&utm_campaign=designshare&utm_medium=link&utm_source=editor
Knit the completed R Markdown file as a HTML document (click the “Knit” button at the top of the script editor window) and upload it to the submission portal on Canvas.