5.1 Introduction
Data is rarely entered directly into R. When we analyze data, getting data into R can either imply
importing data from some file or server (see Section 5.2), or
creating data from scratch (see Section 5.3).
Importing data and creating data frames or tibbles are two possible ways of getting data into R. In both cases, we end up with rectangular data structure known as a data frame or tibble (which a simplified type of data frame, used in the tidyverse (Wickham et al., 2019).
Key concepts
Key concepts of Section 5.2 on importing data include:
- working directory
- file paths (absolute vs. relative)
- importing vs. exporting/reading vs. writing files
Key concepts of Section 5.3 on creating tibbles include:
- rectangular data structures (with rows/cases and columns/variables)
- data frames vs. tibbles
Resources
Resources for Section 5.2 on importing data include:
The base R package utils and the tidyverse package readr (Wickham et al., 2018)
Chapter 6: Importing data of the ds4psy book (Neth, 2022a).
Chapter 11: Data import of the r4ds book (Wickham & Grolemund, 2017).
Resources for Section 5.3 on creating tibbles include:
The R package tibble (Müller & Wickham, 2021)
Chapter 5: Tibbles of the ds4psy book (Neth, 2022a).
Chapter 10: Tibbles of the r4ds book (Wickham & Grolemund, 2017).