R Basics
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 |