readr is an R package for efficiently importing rectangular data files, especially comma-separated values (CSV) files. The read_csv() function reads a CSV into an R data set, typically a tibble, so it can be inspected, wrangled, visualized, and analyzed. section 1.3 section 3.3
A practical readr workflow is:
- Install readr if necessary, then load it directly or load the wider tidyverse with library(tidyverse). section 1.3 section 19.1
- Import a CSV by assigning read_csv("file.csv") to a meaningful object name. section 4.3 section 15.2
- Inspect the result with glimpse() for a compact transposed view, or combine dim() with head() and tail() for dimensions and raw-row previews. section 3.3
- Continue with wrangling, exploratory analysis, visualization, or statistical modeling after checking the imported structure and contents. section 1.3
Importing NBA draft data
draft2 <- read_csv("draft2.csv") glimpse(draft2) # Rows: 291 # Columns: 18 The imported data contains 291 rows and 18 columns, including player, team, position, age, and career variables. Because the file was prepared earlier, the import avoids repeating its previous wrangling. section 3.3
Figure 1.5 A typical chapter flow and, not coincidentally, the typical end-to-end flow of most real-world data science and statistics projects
Follow the end-to-end flow from importing data through preparation, exploration, analysis, and interpretation. section 1.3
