In this problem set, you will investigate objects and data patterns.
Recommend reading R Markdown: The Definative Guide section 3.1 (LINK HERE) before answering these questions
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
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.
df_school_all
?
df_school_all
? What does this specific value of length refer to?
df_school_all
? what does each row represent?
#type of df_school_all
#length of df_school_all
#num of rows in df_school_all
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()
)
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”