Getting started with R programming through simple commands.
# Creating a variable
a <- 5
b = 5
# Exponent
a = 5^2
# Logical
a = 5 # Assign 5 to a
a == 5 # Is a equal to 5?
a != 5 # Is a Not equal to 5?
a < 5 # Is a less than 5?
!(a < 5) # NOT operation
a > 5 # Is a greater than 5?
# Vector
# c() combines values into a vector or list
a = c(1,2,3,4,5)
# length() gives the number of elements in the vector
a <- c(1,2,3,4,5)
length(a)
#Enclosing this with () avoids a separate call to display values in a
(a <- c(1,2,3,4,5))
b = a * a # Replaces each value of a by it's square
b = 5 * a # Scales all values of a by 5
# Matrix
a <- matrix(1:12,ncol=3,nrow=4) # Creates a matrix of size 4x3 with values 1 to 12.