Exercise 2
After working through Exercise 2, you’ll…
- have double-checked whether you understand how to import data
- have learned to subset variables in data frames
- have learned to subset observations and values in data frames
Task 1
Download the “WoJ_names.csv” from LRZ Sync & Share (click here) and put it into the folder that you want to use as working directory.
Set your working directory and load the data into R by saving it into a source object called data.
Note: This time, it’s a csv that is separated by semicolons, not by commas.
Task 2
Now, print only the column to the console that shows the trust in the
government. Use the $
operator first. Then try to achieve the same
result using the subsetting operators, i.e. []
.
Task 3
Print only the first 6 trust in the government numbers to the console.
Use the $
operator first. Then try to achieve the same result using
the subsetting operators, i.e. []
.
When you’re ready to look at the solutions, you can find them here:Solutions for Exercise 2.