3 Data Frames and Tibbles
This lecture introduces you to data frames and tibbles, the best way to organize data. The tidyverse package contains, among others, a starwars tibble that neatly organizes information about different characters:
library(tidyverse)
starwars
# # A tibble: 87 × 14
# name height mass hair_color skin_color eye_color birth_year sex gender homeworld species films vehicles
# <chr> <int> <dbl> <chr> <chr> <chr> <dbl> <chr> <chr> <chr> <chr> <lis> <list>
# 1 Luke Sk… 172 77 blond fair blue 19 male mascu… Tatooine Human <chr… <chr [2…
# 2 C-3PO 167 75 <NA> gold yellow 112 none mascu… Tatooine Droid <chr… <chr [0…
# 3 R2-D2 96 32 <NA> white, blue red 33 none mascu… Naboo Droid <chr… <chr [0…
# 4 Darth V… 202 136 none white yellow 41.9 male mascu… Tatooine Human <chr… <chr [0…
# 5 Leia Or… 150 49 brown light brown 19 fema… femin… Alderaan Human <chr… <chr [1…
# 6 Owen La… 178 120 brown, grey light blue 52 male mascu… Tatooine Human <chr… <chr [0…
# 7 Beru Wh… 165 75 brown light blue 47 fema… femin… Tatooine Human <chr… <chr [0…
# 8 R5-D4 97 32 <NA> white, red red NA none mascu… Tatooine Droid <chr… <chr [0…
# 9 Biggs D… 183 84 black light brown 24 male mascu… Tatooine Human <chr… <chr [0…
# 10 Obi-Wan… 182 77 auburn, wh… fair blue-gray 57 male mascu… Stewjon Human <chr… <chr [1…
# # … with 77 more rows, and 1 more variable: starships <list>
In this session you will learn how to access specific variables or cases from a tibble, how to do complex data transformations and recodes, and finally, how to use an API to import data from the European Social Survey.
Lecture slides: Data Frames and Tibbles
Today’s exercise: Web Excercise 3