The document outlines the agenda for an R for analytics certification training. It includes topics like R installation, RStudio installation, variables, data types, operators, conditional statements, loops, functions, strings. For each topic, it provides brief explanations and syntax examples. The goal is to teach fundamental R programming concepts and skills needed for data analytics using R.
6. `
https://www.edureka.co/r-for-analyticsEDUREKA DATA ANALYTICS WITH R CERTIFICATION TRAINING
Variable
Variables are nothing but reserved memory locations to store values. This means that
when you create a variable you reserve some space in memory.
X = 15
Y <- “Hello”
TRUE -> B
B = TRUE
Y = Hello
X = 15
Memory
8. `
https://www.edureka.co/r-for-analyticsEDUREKA DATA ANALYTICS WITH R CERTIFICATION TRAINING
Data types
A data type, in programming, is a classification that specifies which type of value a variable
has and what type of mathematical, relational or logical operations can be applied to it
without causing an error.
X = 15
Y <- “Hello”
TRUE -> B
B = TRUE
Y = 3.142857
X = 15
Memory
Integer
Numeric
Boolean
10. `
https://www.edureka.co/r-for-analyticsEDUREKA DATA ANALYTICS WITH R CERTIFICATION TRAINING
Vector
A Vector is a sequence of data elements of the same basic type
There are 5 Atomic vectors, also termed as five classes of vectors.
True or False
15L, 30L, 1699L
5, 3.14285, 945678
4+3i, 8+7i
‘A’, “Hey”, ’True’
Integer
Numeric
Complex
Character
Logical
11. `
https://www.edureka.co/r-for-analyticsEDUREKA DATA ANALYTICS WITH R CERTIFICATION TRAINING
Matrix
Matrix are the R objects in which the elements are arranged in a
two-dimensional rectangular layout.
matrix(data, nrow, ncol, byrow, dimnames)
❖ data is the input vector which becomes the data elements of the matrix.
❖ nrow is the number of rows to be created.
❖ ncol is the number of columns to be created.
❖ byrow is a logical clue. If TRUE then the input vector elements are arranged by row.
❖ dimname is the names assigned to the rows and columns.
Syntax
12. `
https://www.edureka.co/r-for-analyticsEDUREKA DATA ANALYTICS WITH R CERTIFICATION TRAINING
Array
Arrays are the R data objects which can store data in more than
two dimensions.
array( data, dim, dimnames)
array( c(0:15), dim=c( 4,4,2,2) )
Syntax
13. `
https://www.edureka.co/r-for-analyticsEDUREKA DATA ANALYTICS WITH R CERTIFICATION TRAINING
Lists
Lists are the R objects which contain elements of different types
like − numbers, strings, vectors and another list inside it.
list(data)Syntax
vtr1 <- c(1:5)
vtr2 <- c("hi", "Hello", "How are you")
vtr3 <-c(TRUE,TRUE, FALSE, FALSE)
myList <- list(vtr1,vtr2, vtr3)
14. `
https://www.edureka.co/r-for-analyticsEDUREKA DATA ANALYTICS WITH R CERTIFICATION TRAINING
Data Frame
Data Frame is a table or a two-dimensional array-like structure in
which each column contains values of one variable and each row
contains one set of values from each column.
data.frame(data)Syntax
data.frame(mtcars)
16. `
https://www.edureka.co/r-for-analyticsEDUREKA DATA ANALYTICS WITH R CERTIFICATION TRAINING
Data Operators in R
Operators
Relational
Operators
Arithmetic
Operators
Logical
Operators
Assignment
Operations Operators are the constructs which can manipulate the value of operands.
17. `
https://www.edureka.co/r-for-analyticsEDUREKA DATA ANALYTICS WITH R CERTIFICATION TRAINING
Arithmetic and Relational Operators
Arithmetic
a + b
a – b
a * b
a / b
a %% b
a^b
a%/%b
Subtraction
Division
Multiplication
Modulus
Exponent
a == b
a != b
a > b
a < b
a >= b
a <= b
Equal To
Greater Than
Not Equal To
Less Than
Greater Than Equal To
Less Than Equal To
Relational
Addition
Floor Division
19. `
https://www.edureka.co/r-for-analyticsEDUREKA DATA ANALYTICS WITH R CERTIFICATION TRAINING
Logical Operator
There are three types of logical operators: AND, NOT, OR
a & b
It combines each element of vectors and gives a output
TRUE if both the elements are TRUE.
a | b It combines each element of the vectors and gives a
output TRUE if one the elements is TRUE.
!a Takes each element of the vector and gives the opposite
logical value.
24. `
https://www.edureka.co/r-for-analyticsEDUREKA DATA ANALYTICS WITH R CERTIFICATION TRAINING
Conditional Statements
Switch case Statement
Syntax:
Start
switch
Condition
Case value1 Statement 1
Case value2 Statement 2
Case value3 Statement 3
default Statement
End
27. `
https://www.edureka.co/r-for-analyticsEDUREKA DATA ANALYTICS WITH R CERTIFICATION TRAINING
Repeat Loop
repeat Repeats a statement or group of statements while a given condition is TRUE. It
tests the condition after executing the loop body.
Syntax:
CHECK
CONDITION
EXECUTE BLOCK
START
EXIT LOOPFALSE
TRUE
repeat
28. `
https://www.edureka.co/r-for-analyticsEDUREKA DATA ANALYTICS WITH R CERTIFICATION TRAINING
While Loop
while Loop Repeats a statement or group of statements while a given condition is TRUE. It
tests the condition before executing the loop body.
Syntax:
CHECK
CONDITION
EXECUTE BLOCK
START
repeat
EXIT LOOP
FALSE
TRUE
29. `
https://www.edureka.co/r-for-analyticsEDUREKA DATA ANALYTICS WITH R CERTIFICATION TRAINING
For Loop
for Loop Repeats a statement or group of for a fixed number of times. It tests the
condition before executing the loop body.
Syntax:
Check
condition
Initialization
START
Iteration
Execute Statements
Exit loop
FALSE
TRUE
repeat
32. `
https://www.edureka.co/r-for-analyticsEDUREKA DATA ANALYTICS WITH R CERTIFICATION TRAINING
String in R
Sequence Operations:
➢ Concatenation:
str1<- ‘Hi’
str2<- “How are you?”
paste(str1,str2) "Hi How are you? "
➢ Character Count:
nchar(str)str<-“Edureka” 7
➢ Case Change
toupper(str)
tolower(str)
str<-“Edureka”
EDUREKA
edureka
➢ Substring
substring(str, 3, 6)str<-“Edureka” “urek”
34. `
https://www.edureka.co/r-for-analyticsEDUREKA DATA ANALYTICS WITH R CERTIFICATION TRAINING
Functions
A function is a block of organized, reusable code that is used to perform a
single, related action.
Functions
Predefined
Functions
User Defined
Functions
Function Add
Call (3,5)
Call (6,9)
Call (1,5)
Call 1
Call 2
Call 3
Return 8
Return 15
Return 6
Functions In R