2 Vectors
This lecture introduces you to R’s most fundamental data type, Vectors:
# Concatenate the sequence 5 4 3 2 1 to a vector,
# assign it to object x1, and print it.
(x1 <- c(5, 4, 3, 2, 1))
# [1] 5 4 3 2 1
You will learn the differences between numeric, factor, date, character and logical vectors, as well as how to transform, recode, and manipulate them. This lecture might seem rather abstract and technical at times. But you will get hung up quickly if you don’t take your time to learn about vectors.
Lecture slides: Vectors
Today’s exercise: Web Excercise 2
Homework
- Finish web exercises 1 and 2.
- Take a close look at the codebook of the ESS9 below. Identify all variables that could be taken as indicators of homophobia. Start a new R script for your homework, add the tidyverse to your library, and finally use the
#
operator to note the names of the variables you have identified. For example,cntry
is the name of the variable identifying the respondents’ country of residence. - Read Chapter 6 Workflow: Scripts
- Read Chapter 8 Workflow: Projects