7 Base R Quiz

7.1 Instruction on the quiz

  • Quiz 1 consists of 5 multiple-choice problems.

  • Solve each of five problems in your own R markdown file.

    • You DON’T need to submit any R markdown file for Quiz 1.
  • Once you solve all problems, then go to cyber campus and find Quiz 1.

  • Please mark the right answer to each of the 5 multiple choice problems.

  • Some quiz problems need the round() function, which will return the integer part of the provided number. For quiz responses, please round your answers to the two decimal place.

# round to the two decimal place
round(3.141592, digits = 2)
## [1] 3.14

7.2 Dataset: bfi is a dataset in the psych package containing 25 personality self report items taken from the International Personality Item Pool. In the dataset,

  1. gender represents gender (Males = 1, Females = 2),
  2. education represent educational attainment (1 = HS, 2 = finished HS, 3 = some college, 4 = college graduate 5 = graduate degree),
  3. age represents age in years, and
  4. E3 is one of the five items that measures extraversion (“Know how to captivate people”).
# You need to install and load the `psych` package to use the `bfi` dataset.
library(psych)

Let’s create three vectors for gender, education, and age variables in the diamonds dataset.

gender <- bfi$gender
education <- bfi$education
age <- bfi$age
E3 <- bfi$E3

7.3 Quiz problem 1

What is the type of each of these vectors (character, integer, double, factor)?

7.4 Quiz problem 2

What proportion of the sample is females?

7.5 Quiz problem 3

What is the sample mean difference in E3 between males (gender = 1) younger than (<) 26 and females (gender = 2) younger than (<) 26? That is, mean of E3 for males younger than 26 - mean of E3 for females younger than 26.

7.6 Quiz problem 4

In the bfi dataset, how many males with age 16 and highschool degree are there?

7.7 Quiz problem 5

Using the bfi data set, what is the count of 42 year old females?