
π This article includes 2 downloadable practice files β
library(readr)
sales <- read_csv("sales.csv")
head(sales); nrow(sales); summary(sales$qty)
library(readxl)
x <- read_excel("file.xlsx", sheet = "Data")
write_csv(sales, "sales_copy.csv")
read_csv shows the type it guessed for each column; fix wrong guesses with col_types. Missing values are NA; most functions need na.rm = TRUE to ignore them (e.g. mean(x, na.rm = TRUE)).
Code for this course follows standard, current syntax; we test JavaScript and PowerShell scripts before publishing, and R/Java/Rust examples are kept to core language features. Tell us if anything fails on your setup.
Practice
Read sales.csv and check its structure.
π Practice files for this article
β¬ Download all 2 files (ZIP Β· 662 B)
- πr-03-read-data.RLesson code file.β¬ R Β· 206 B
- π§Ύsales.csv40 sample orders used by the scripts.β¬ CSV Β· 1 KB
Free to use for learning. Files with macros (.bas) are plain text β import them with Alt+F11 β File β Import File, and always test on a copy.
Stuck on a step? Ask a question and the AI answers using this article.