# ============================================================
# Reading Data into R
# R Foundations — Rverse Analytics
# https://rverseanalytics.com/learn/reading-data
# ============================================================

# R reads files relative to the working directory
getwd()
# Write a CSV, then read it back in
write.csv(mtcars, "cars.csv", row.names = FALSE)
cars <- read.csv("cars.csv")
# Always inspect a data frame right after importing
str(cars)
head(cars)
# Real files: give the path (or use readr for speed)
# cars <- read.csv("data/cars.csv")
# library(readr); cars <- read_csv("data/cars.csv")
dim(cars)
