`read_csv()` imports a comma-separated-values file into an R data object. It comes from the `readr` package, part of the tidyverse, and is the starting point for examining, cleaning, visualizing, and analyzing NBA data. section 1.3 section 2.2
Give `read_csv()` a quoted filename or file path, then assign the imported data to an object with `<-`. If the file is in the current working directory, its filename and `.csv` extension are enough; otherwise, provide its location or select it interactively with `file.choose()`. A file outside the working directory will not load when only its filename is supplied. section 2.2 section 5.2
draft <- read_csv("draft.csv")
This minimal call imports draft-pick data and stores it in an object named `draft`. section 2.2
A practical import-and-check routine is:
- Load `readr` before calling `read_csv()`, after installing the package if needed. section 1.3
- Import each CSV into a clearly named object; multiple files require multiple calls. section 6.2 section 14.2.4
- Confirm the row and column counts with `dim()` immediately after importing. section 2.2 section 9.2
- Inspect variables and a compact data preview with `glimpse()` before wrangling. section 3.3 section 8.3
Checking a large play-by-play import
A 2019–20 play-by-play CSV is imported as `pbp`, then inspected with `glimpse()`. The preview reports 543,149 rows and 44 columns, while displaying variable names, inferred types, and sample values. Large files may take several seconds to load on a personal computer; inspect them before selecting, filtering, or converting variables. section 8.3 section 16.2
Importing is not the analysis. Raw files can include unneeded columns, missing values, duplicated records, or formats that do not fit the question. After loading, narrow the data, create needed variables, reshape or join data sets, and validate each important transformation before modeling or statistical testing. section 14.2 section 12.3




