Answers - Excercise 00

Author
Affiliations
John R Little

Duke University

Published

January 6, 2023

exercise 00:

  1. Load the tidyverse libary package
library(tidyverse)
  1. Fill in the blanks. Using what you’ve seen in class, if data/brodheadCenter.csv is a CSV (comma separated values) file, how would you load the file into a new object called brodhead?
brodhead  <- read_csv("../../data/brodheadCenter.csv")
  1. Display your new brodhead data frame?
brodhead
  1. starwars is an on-board dataset that comes with the tidyverse. Insert a new code chunk and display that data.
starwars
  1. Copy and paste the following code into a new code chunk in your new file.
starwars %>% 
  ggplot(aes(fct_infreq(hair_color))) + 
  geom_bar() + 
  ggtitle("Hair Color Frequency of Star Wars Characters")

  1. Take a look at the structure of the brodhead object.
    • How many observations (rows) are there?
    • How many variables (columns) are there?
    • How many of the variables are numeric data?
glimpse(brodhead)
Rows: 59
Columns: 7
$ name     <chr> "Devils Krafthouse", "Devils Krafthouse", "Devils Krafthouse"…
$ type     <chr> "bar and grill", "bar and grill", "bar and grill", "bar and g…
$ menuType <chr> "appetizer", "appetizer", "appetizer", "appetizer", "appetize…
$ itemType <chr> "snack", "snack", "snack", "snack", "snack", "snack", "snack"…
$ itemName <chr> "sweet potato tots", "french fries", "quesadillas", "southwes…
$ cost     <dbl> 4, 4, 6, 8, 7, 8, 9, 4, 9, 9, 9, 8, 4, 7, 7, 7, 8, 8, 9, 9, 9…
$ rating   <dbl> 8, 10, 5, 6, 7, 8, 5, 6, 5, 5, 6, 6, 8, 6, 7, 5, 6, 5, 4, 5, …