R Lang
R Lang
Introduction to R
• Var1 = “Simple”
• Var2 <- “left”
• “Right” -> Var 3
Variables
R Data Types
• Numerics: Decimal (floating point values) are part of the numeric
class in R
• Integers: Natural (whole) numbers are known as integers and
are also part of the numeric class
• Logical : Boolean values (True and False) are part of the logical
class. In R these are written in All Caps.
Characters
Comments in R
• Single line comments can be written by using #
https://cran.r-project.org/doc/contrib/Short-refcard.pdf
Vector Comparisons
• v <- c(1,2,3,4,5)
• v <- 2
TRUE FALSE FALSE FALSE FALSE
• v == 3
• FALSE FALSE TRUE FALSE FALSE
Creating a Matrix
Creating Matrices from Vectors
Naming Matrices
Matrix Selection and Indexing
Matrix Arithmetic
Matrix Arithmetic with multiple matrices
Matrix multiplication
Matrix Operations
Binding columns and rows