R Lesson 3: Reading CSV and Excel

📎 This article includes 2 downloadable practice files ↓

⏱ 1 min read

📘 R Beginner Course · Lesson 3 of 6

“`r
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)).

💡 For dd-mm-yyyy dates use lubridate::dmy(); for yyyy-mm-dd use ymd().

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

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.

✨ Ask AI about this article

Stuck on a step? Ask a question and the AI answers using this article.

Free · AI can be wrong