360 likes | 410 Views
This Edureka R Programming Tutorial For Beginners (R Tutorial Blog: https://goo.gl/mia382) will help you in understanding the fundamentals of R and will help you build a strong foundation in R. Below are the topics covered in this tutorial: <br><br>1. Variables <br>2. Data types <br>3. Operators <br>4. Conditional Statements <br>5. Loops <br>6. Strings <br>7. Functions
E N D
` EDUREKA DATA ANALYTICS WITH R CERTIFICATION TRAINING What is Hadoop? https://www.edureka.co/r-for-analytics
Agenda ➢ Variables ➢ Data types ➢ Operators ` ➢ Conditional Statements ➢ Loops ➢ Strings ➢ Functions EDUREKA DATA ANALYTICS WITH R CERTIFICATION TRAINING https://www.edureka.co/r-for-analytics
R Installation ` EDUREKA DATA ANALYTICS WITH R CERTIFICATION TRAINING https://www.edureka.co/r-for-analytics
RStudio Installation ` EDUREKA DATA ANALYTICS WITH R CERTIFICATION TRAINING https://www.edureka.co/r-for-analytics
Conditional Statements Data types Strings ` Functions Operators Loops Variables EDUREKA DATA ANALYTICS WITH R CERTIFICATION TRAINING https://www.edureka.co/r-for-analytics
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. Memory ` X = 15 X = 15 Y <- “Hello” TRUE -> B Y = Hello B = TRUE EDUREKA DATA ANALYTICS WITH R CERTIFICATION TRAINING https://www.edureka.co/r-for-analytics
Data types Conditional Statements Strings ` Functions Operators Loops Variables EDUREKA DATA ANALYTICS WITH R CERTIFICATION TRAINING https://www.edureka.co/r-for-analytics
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. Memory ` Integer X = 15 X = 15 Y <- “Hello” TRUE -> B Numeric Y = 3.142857 Boolean B = TRUE EDUREKA DATA ANALYTICS WITH R CERTIFICATION TRAINING https://www.edureka.co/r-for-analytics
Data types Data types ` EDUREKA DATA ANALYTICS WITH R CERTIFICATION TRAINING https://www.edureka.co/r-for-analytics
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. Logical True or False ` Integer 15L, 30L, 1699L Numeric 5, 3.14285, 945678 Complex 4+3i, 8+7i Character ‘A’, “Hey”, ’True’ EDUREKA DATA ANALYTICS WITH R CERTIFICATION TRAINING https://www.edureka.co/r-for-analytics
Matrix Matrix are the R objects in which the elements are arranged in a two-dimensional rectangular layout. matrix(data, nrow, ncol, byrow, dimnames) Syntax ` ❖ 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. EDUREKA DATA ANALYTICS WITH R CERTIFICATION TRAINING https://www.edureka.co/r-for-analytics
Array Arrays are the R data objects which can store data in more than two dimensions. Syntax array( data, dim, dimnames) ` array( c(0:15), dim=c( 4,4,2,2) ) EDUREKA DATA ANALYTICS WITH R CERTIFICATION TRAINING https://www.edureka.co/r-for-analytics
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) EDUREKA DATA ANALYTICS WITH R CERTIFICATION TRAINING https://www.edureka.co/r-for-analytics
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) EDUREKA DATA ANALYTICS WITH R CERTIFICATION TRAINING https://www.edureka.co/r-for-analytics
Conditional Statements Data types Strings ` Functions Loops Variables Operators EDUREKA DATA ANALYTICS WITH R CERTIFICATION TRAINING https://www.edureka.co/r-for-analytics
Data Operators in R Operations Operators are the constructs which can manipulate the value of operands. Arithmetic Operators Relational Operators ` Operators Logical Operators Assignment EDUREKA DATA ANALYTICS WITH R CERTIFICATION TRAINING https://www.edureka.co/r-for-analytics
Arithmetic and Relational Operators Relational Arithmetic a + b Addition a – b Subtraction a == b Equal To ` a * b a != b Multiplication Not Equal To a / b a > b Greater Than Division a < b a %% b Less Than Modulus a >= b Greater Than Equal To a^b Exponent a <= b Less Than Equal To a%/%b Floor Division EDUREKA DATA ANALYTICS WITH R CERTIFICATION TRAINING https://www.edureka.co/r-for-analytics
Assignment Operator There are two types of Assignment operators: Left and Right Equals x=5 Left ` Assign x<- 15 Equals 20=x Right 25 -> x Assign EDUREKA DATA ANALYTICS WITH R CERTIFICATION TRAINING https://www.edureka.co/r-for-analytics
Logical Operator There are three types of logical operators: AND, NOT, OR 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 | b Takes each element of the vector and gives the opposite logical value. !a EDUREKA DATA ANALYTICS WITH R CERTIFICATION TRAINING https://www.edureka.co/r-for-analytics
Conditional Statements ` Data types Strings Functions Loops Operators Variables EDUREKA DATA ANALYTICS WITH R CERTIFICATION TRAINING https://www.edureka.co/r-for-analytics
Conditional Statements If Statement Start Syntax: If Condition ` TRUE FALSE If code End EDUREKA DATA ANALYTICS WITH R CERTIFICATION TRAINING https://www.edureka.co/r-for-analytics
Conditional Statements Else If Statement Start Syntax: FALSE If Else If Condition Condition ` FALSE TRUE TRUE If code Else If code End EDUREKA DATA ANALYTICS WITH R CERTIFICATION TRAINING https://www.edureka.co/r-for-analytics
Conditional Statements Else Statement Start Syntax: FALSE If Else If Condition Condition ` FALSE TRUE TRUE Else code If code Else If code End EDUREKA DATA ANALYTICS WITH R CERTIFICATION TRAINING https://www.edureka.co/r-for-analytics
Conditional Statements Start Switch case Statement switch Condition Syntax: Case value1 Statement 1 ` Case value2 Statement 2 Case value3 Statement 3 default Statement End EDUREKA DATA ANALYTICS WITH R CERTIFICATION TRAINING https://www.edureka.co/r-for-analytics
Conditional Statements Strings Data types ` Functions Operators Variables Loops EDUREKA DATA ANALYTICS WITH R CERTIFICATION TRAINING https://www.edureka.co/r-for-analytics
Loops in R A loop statement allows us to execute a statement or group of statements multiple times. Loops Loops ` while repeat for EDUREKA DATA ANALYTICS WITH R CERTIFICATION TRAINING https://www.edureka.co/r-for-analytics
Repeat Loop Repeats a statement or group of statements while a given condition is TRUE. It tests the condition after executing the loop body. repeat Syntax: START ` EXECUTE BLOCK repeat TRUE CHECK CONDITION EXIT LOOP FALSE EDUREKA DATA ANALYTICS WITH R CERTIFICATION TRAINING https://www.edureka.co/r-for-analytics
While Loop Repeats a statement or group of statements while a given condition is TRUE. It tests the condition before executing the loop body. while Loop Syntax: START ` FALSE CHECK CONDITION TRUE repeat EXIT LOOP EXECUTE BLOCK EDUREKA DATA ANALYTICS WITH R CERTIFICATION TRAINING https://www.edureka.co/r-for-analytics
For Loop Repeats a statement or group of for a fixed number of times. It tests the condition before executing the loop body. for Loop Syntax: START Initialization ` FALSE Check condition Exit loop TRUE repeat Execute Statements Iteration EDUREKA DATA ANALYTICS WITH R CERTIFICATION TRAINING https://www.edureka.co/r-for-analytics
Strings Conditional Statements Data types ` Functions Operators Variables Loops EDUREKA DATA ANALYTICS WITH R CERTIFICATION TRAINING https://www.edureka.co/r-for-analytics
String in R Any value written within a pair of single quote or double quotes in R is treated as a string. Syntax: ` EDUREKA DATA ANALYTICS WITH R CERTIFICATION TRAINING https://www.edureka.co/r-for-analytics
String in R Sequence Operations: ➢ Concatenation: str1<- ‘Hi’ str2<- “How are you?” "Hi How are you? " paste(str1,str2) ➢ Character Count: ` str<-“Edureka” nchar(str) 7 ➢ Case Change toupper(str) tolower(str) EDUREKA edureka str<-“Edureka” ➢ Substring str<-“Edureka” substring(str, 3, 6) “urek” EDUREKA DATA ANALYTICS WITH R CERTIFICATION TRAINING https://www.edureka.co/r-for-analytics
Conditional Statements Strings Data types Operators Variables Loops Functions https://www.edureka.co/r-for-analytics EDUREKA DATA ANALYTICS WITH R CERTIFICATION TRAINING
Functions In R A function is a block of organized, reusable code that is used to perform a single, related action. Functions Function Add Functions ` Return 8 Call 1 Call (3,5) Return 15 Call 2 Predefined Functions User Defined Functions Call (6,9) Call 3 Return 6 Call (1,5) EDUREKA DATA ANALYTICS WITH R CERTIFICATION TRAINING https://www.edureka.co/r-for-analytics
Session In A Minute Data Operators Data Types Install R & RStudio ` Functions Conditional Statements Loops EDUREKA DATA ANALYTICS WITH R CERTIFICATION TRAINING https://www.edureka.co/r-for-analytics