R Basics

📊 Welcome to R Basics! Whether you’re new to coding or brushing up on the essentials, this section will help you get comfortable writing R code and thinking like a Data Scientist. You’ll explore fundamental topics like Data Types, Variables, and Data Structures—everything you need to start analyzing data with confidence. Let’s get started!

Summary Table

Summary of the R Basics section.

Concept Example Description
numeric / double 3.14, 10 Numbers (with or without decimals), stored as double
integer 10L Whole numbers with L suffix
character "GW" Text (strings)
logical TRUE, FALSE Boolean values
raw charToRaw("Tyler") Binary data in raw byte format
NULL NULL Represents no value
Assignment x <- 10, y = 3.14 Assign value to a variable
Naming value, .value, Value Variable names must follow rules and are case-sensitive
Reassignment x <- x + 1 Update variable value
Multiple Assignment a <- b <- c <- 0 Assign same value to multiple variables
Dynamic Typing x <- 5 then x <- "five" Variables can change type
vector c(95, 88, 90) One-dimensional, same type
list list(name = "Intro", code = 6101) Collection of different types
matrix matrix(c(1, 2, 3, 4), nrow = 2) 2D, same type structure
data.frame data.frame(name = "Alice", score = 95) Tabular structure with columns of possibly mixed types
factor factor(c("male", "female")) Categorical data with levels