In this problem set, you will investigate objects and data patterns.

Step 1: Make changes to YAML header

Recommend reading R Markdown: The Definative Guide section 3.1 (LINK HERE) before answering these questions

  1. Add a table of contents to YAML header
  2. table of contents should have “depth” of 2
  3. table of contents should “float”
  4. add section numbering to headers

Load tidyverse package [code already provided]

#install.packages("tidyverse") #install if you do not have tidyverse installed
library(tidyverse)
#> ── Attaching packages ────────────────────────────────── tidyverse 1.3.0 ──
#> ✓ ggplot2 3.3.2     ✓ purrr   0.3.4
#> ✓ tibble  3.0.3     ✓ dplyr   1.0.2
#> ✓ tidyr   1.1.1     ✓ stringr 1.4.0
#> ✓ readr   1.3.1     ✓ forcats 0.5.0
#> ── Conflicts ───────────────────────────────────── tidyverse_conflicts() ──
#> x dplyr::filter() masks stats::filter()
#> x dplyr::lag()    masks stats::lag()

Load data frame object and use count() to tabulate the total number of visits each school received [code already provided]

rm(list = ls()) # remove all objects
getwd()
#> [1] "/Users/karinasalazar/rclass/lectures/lecture2"

load(url("https://github.com/ozanj/rclass/raw/master/data/recruiting/recruit_school_allvars.RData"))
#glimpse(df_school_all)

df_school_all %>% count(total_visits)
#> # A tibble: 25 x 2
#>    total_visits     n
#>           <int> <int>
#>  1            0 15405
#>  2            1  2718
#>  3            2  1324
#>  4            3   671
#>  5            4   395
#>  6            5   263
#>  7            6   152
#>  8            7   107
#>  9            8    89
#> 10            9    57
#> # … with 15 more rows

Step 2: Investigating objects

  1. Answer the following questions about the object df_school_all by running the appropriate R commands within the code chunk and writing any substantive response required next to the question. The code and substantive response for the first question will be answered for you as an example.
    • What “type” of object is df_school_all?
      • ANSWER [FREEBIE]: the object df_school_all is a list type
    • What is the “length” of the object df_school_all? What does this specific value of length refer to?
      • YOUR ANSWER HERE
    • how many “rows” are in the object df_school_all? what does each row represent?
      • YOUR ANSWER HERE
#type of df_school_all 

#length of df_school_all 

#num of rows in df_school_all
  1. In the below code chunk, use the str() function to describe the contents of df_school_all and then answer the following questions in text above the code chunk.
    • What does each element of the object df_school_all represent? (hint Lecture 1.2)

    • Are the individual elements within df_school_all lists or vectors?

    • Are the individual elements within df_school_all named or un-named? what do these element names refer to? (hint use names())

  1. These questions refer to the variable school_type within the object df_school_all. Run the appropriate R commands in the chunk below and write substantive responses below each question.

    • What is the data “type” of school_type?

      - __ANSWER__:
    • What is the “length” of school_type? What does this specific value of length refer to?

      - __ANSWER__:

Once finished, knit to (HTML) and upload both .Rmd and HTML files

Remember to use this naming convention “lastname_firstname_ps2”