1 / 62

R Tutorial For Beginners | R Programming Tutorial l R Language For Beginners | R Training | Edureka

This Edureka R Tutorial (R Tutorial Blog: https://goo.gl/mia382) will help you in understanding the fundamentals of R tool and help you build a strong foundation in R. Below are the topics covered in this tutorial: <br><br>1. Why do we need Analytics ? <br>2. What is Business Analytics ? <br>3. Why R ? <br>4. Variables in R <br>5. Data Operator <br>6. Data Types <br>7. Flow Control <br>8. Plotting a graph in R

EdurekaIN
Download Presentation

R Tutorial For Beginners | R Programming Tutorial l R Language For Beginners | R Training | Edureka

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. EDUREKA DATA ANALYTICS WITH R CERTIFICATION TRAINING What is Hadoop? https://www.edureka.co/r-for-analytics

  2. Agenda ➢ Why do we need Analytics ? ➢ What is Business Analytics ? ➢ Why R ? ➢ Variables in R ➢ Data Operator ➢ Data Types ➢ Flow Control ➢ Plotting a graph in R https://www.edureka.co/r-for-analytics EDUREKA DATA ANALYTICS WITH R CERTIFICATION TRAINING

  3. Why do we need Analytics? https://www.edureka.co/r-for-analytics EDUREKA DATA ANALYTICS WITH R CERTIFICATION TRAINING

  4. Why do we need Analytics? ➢ Data analytics helps organizations harness their data and use it to identify new opportunities. https://www.edureka.co/r-for-analytics EDUREKA DATA ANALYTICS WITH R CERTIFICATION TRAINING

  5. What is Business Analytics? https://www.edureka.co/r-for-analytics EDUREKA DATA ANALYTICS WITH R CERTIFICATION TRAINING

  6. What is Business Analytics? ➢ Business analytics examines large and different types of data to uncover hidden patterns, correlations and other insights. Data Analytics Decisions https://www.edureka.co/r-for-analytics EDUREKA DATA ANALYTICS WITH R CERTIFICATION TRAINING

  7. What is Data Visualization? ➢ Visualization allows us visual access to huge amounts of data in easily digestible visuals. ➢ Well designed data graphics are usually the simplest and at the same time, the most powerful. https://www.edureka.co/r-for-analytics EDUREKA DATA ANALYTICS WITH R CERTIFICATION TRAINING

  8. Data Visualization ➢ Below are some of the most popular tools used for Data Analytics and Data Visualization: https://www.edureka.co/r-for-analytics EDUREKA DATA ANALYTICS WITH R CERTIFICATION TRAINING

  9. Why R? https://www.edureka.co/r-for-analytics EDUREKA DATA ANALYTICS WITH R CERTIFICATION TRAINING

  10. Why R? Programming and Statistical Language Apart from being used as a statistical language , it can also be used a programming language for analytical purposes. Data Analysis and Visualization Apart from being one of the most dominant analytics tools, R also is one of the most popular tools used for data visualization. https://www.edureka.co/r-for-analytics EDUREKA DATA ANALYTICS WITH R CERTIFICATION TRAINING

  11. Why R? Simple and Easy to Learn R is a simple and easy to learn, read & write Free and Open Source R is an example of a FLOSS (Free/Libre and Open Source Software) which means one can freely distribute copies of this software, read it's source code, modify it, etc. https://www.edureka.co/r-for-analytics EDUREKA DATA ANALYTICS WITH R CERTIFICATION TRAINING

  12. Installation Steps https://www.edureka.co/r-for-analytics EDUREKA DATA ANALYTICS WITH R CERTIFICATION TRAINING

  13. R Installation Go to https://cran.r- project.org 1 Download and install R 3.3.3 on your system 2 https://www.edureka.co/r-for-analytics EDUREKA DATA ANALYTICS WITH R CERTIFICATION TRAINING

  14. RStudio IDE Installation Go to https://www.rstudio.com/ 1 C/C++ Download and install Rstudio on your system 2 https://www.edureka.co/r-for-analytics EDUREKA DATA ANALYTICS WITH R CERTIFICATION TRAINING

  15. Fundamental Concepts of R Selection Statements Data Operator Data Types Loops Variables https://www.edureka.co/r-for-analytics EDUREKA DATA ANALYTICS WITH R CERTIFICATION TRAINING

  16. Variables in R ➢ 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 = 25 X = 25 Y <- “Hello” TRUE -> B Y = Hellp B = TRUE https://www.edureka.co/r-for-analytics EDUREKA DATA ANALYTICS WITH R CERTIFICATION TRAINING

  17. Fundamental Concepts of R Data Operators Selection Statements Variables Data Types Loops https://www.edureka.co/r-for-analytics EDUREKA DATA ANALYTICS WITH R CERTIFICATION TRAINING

  18. Data Operators in R 1 Arithmetic Operators 2 Assignment Operators 3 Relational Operators 4 Logical Operators 5 Special Operators https://www.edureka.co/r-for-analytics EDUREKA DATA ANALYTICS WITH R CERTIFICATION TRAINING

  19. Arithmetic Operators + >> 2 + 3 5 >> +2 Add two operands or unary plus 1 Arithmetic Operators - >> 3 – 1 2 >> -2 Subtract two operands or unary subtract 2 Assignment Operators Relational Operators 3 * >> 2 * 3 6 Multiply two operands 4 Logical Operators 5 Special Operators / Divide left operand with the right and result is in float >> 6 / 3 2.0 https://www.edureka.co/r-for-analytics EDUREKA DATA ANALYTICS WITH R CERTIFICATION TRAINING

  20. Arithmetic Operators ^ 1 Arithmetic Operators >> 2 ^ 3 8 Left operand raised to the power of right 2 Assignment Operators %% Remainder of the division of left operand by the right >> 5 %% 2 1 Relational Operators 3 4 Logical Operators %/% Division that results into whole number adjusted to the left in the number line >> 7 %/ %3 2 5 Special Operators https://www.edureka.co/r-for-analytics EDUREKA DATA ANALYTICS WITH R CERTIFICATION TRAINING

  21. Assignment Operators = >> x=5 >>x 5 x = <right operand> 1 Arithmetic Operators <− >> x<- 15 >> x 15 2 Assignment Operators x <- <right operand> Relational Operators 3 <<− >> x <<- 2 >> x 2 x <<- <right operand> Logical Operators 4 5 Special Operators -> >> 25 -> x >> x 25 <left operand> -> x https://www.edureka.co/r-for-analytics EDUREKA DATA ANALYTICS WITH R CERTIFICATION TRAINING

  22. Relational Operators > >> 2 > 3 False True if left operand is greater than the right 1 Arithmetic Operators < >> 2 < 3 True 2 Assignment Operators True if left operand is less than the right 3 Relational Operators == >>2 == 2 True True if left operand is equal to right Logical Operators 4 5 Special Operators != >> x >>= 2 >>print(x) 1 True if left operand is not equal to the right https://www.edureka.co/r-for-analytics EDUREKA DATA ANALYTICS WITH R CERTIFICATION TRAINING

  23. Relational Operators 1 Arithmetic Operators >= >> 2 > =3 False True if left operand is greater than or equal to the right operand 2 Assignment Operators 3 Relational Operators =< >> 2 =< 3 True Logical Operators 4 True if left operand is less than or equal to the right operand 5 Special Operators https://www.edureka.co/r-for-analytics EDUREKA DATA ANALYTICS WITH R CERTIFICATION TRAINING

  24. Logical Operators & >> 2 & 3 3 1 Arithmetic Operators Returns x if x is False , y otherwise 2 Assignment Operators | >> 2 | 3 2 Returns y if x is False, x otherwise 3 Relational Operators 4 Logical Operators ! >> ! 1 False Returns True if x is True, False otherwise 5 Special Operators https://www.edureka.co/r-for-analytics EDUREKA DATA ANALYTICS WITH R CERTIFICATION TRAINING

  25. Special Operators 1 Arithmetic Operators : >> x <- 2:8 >> x [1]2 3 4 5 6 7 8 It creates the series of numbers in sequence for a vector 2 Assignment Operators 3 Relational Operators %in% >> x <- 2:8 >> y <- 5 >>y %in% x True 4 Logical Operators This operator is used to identify if an element belongs to a vector. 5 Special Operators https://www.edureka.co/r-for-analytics EDUREKA DATA ANALYTICS WITH R CERTIFICATION TRAINING

  26. Fundamental Concepts of R Selection Statements Data Operator Variable Loops Data Types https://www.edureka.co/r-for-analytics EDUREKA DATA ANALYTICS WITH R CERTIFICATION TRAINING

  27. Data Type ➢ We do not need to declare a variables before using them. C/C++ https://www.edureka.co/r-for-analytics EDUREKA DATA ANALYTICS WITH R CERTIFICATION TRAINING

  28. Data Type Vectors ➢ A Vector is a sequence of data elements of the same basic type. Example: vtr = (1, 3, 5 ,7 9) or vtr <- (1, 3, 5 ,7 9) Lists Arrays Matrices Factors ➢ There are 5 Atomic vectors, also termed as five classes of vectors. Data Frames https://www.edureka.co/r-for-analytics EDUREKA DATA ANALYTICS WITH R CERTIFICATION TRAINING

  29. Data Type Vectors Lists Arrays Matrices Factors Data Frames https://www.edureka.co/r-for-analytics EDUREKA DATA ANALYTICS WITH R CERTIFICATION TRAINING

  30. Data Type Sequence Operations: Vectors ➢ Indexing Lists List(2:4) list <- c(“a” , “b” , “c” ,”d”) “b” “c” “d” Arrays ➢ Replacing Matrices “a” , “f” , “c” ,”d” list <- c(“a” , “b” , “c” ,”d”) list[2]<- “f’ Factors ➢ sort() Data Frames list <- c(4 , 6, 3, 8, 1) Sorted<- sort(list) 1 3 4 6 8 https://www.edureka.co/r-for-analytics EDUREKA DATA ANALYTICS WITH R CERTIFICATION TRAINING

  31. Data Type Vectors ➢ Lists are the R objects which contain elements of different types like − numbers, strings, vectors and another list inside it. Lists Arrays > n = c(2, 3, 5) > s = c("aa", "bb", "cc", "dd", "ee") >x = list(n, s, TRUE) Matrices Factors Data Frames https://www.edureka.co/r-for-analytics EDUREKA DATA ANALYTICS WITH R CERTIFICATION TRAINING

  32. Data Type Sequence Operations: Vectors ➢ Merging list1 <- list(1,2,3) list2 <- list("Sun","Mon","Tue") 1 2 3 Lists merged.list <- c(list1,list2) Sun Mon Tue Arrays ➢ Slicing list1 <- list(1,2,3) list2 <- list("Sun","Mon","Tue") List3 <- c(list1, list2) Matrices List3[2] Sun Mon Tue Factors ➢ Indexing Data Frames string1[-1] + string[1] list1 <- list(1,2,3) ‘da’ https://www.edureka.co/r-for-analytics EDUREKA DATA ANALYTICS WITH R CERTIFICATION TRAINING

  33. Data Type Vectors ➢ Arrays are the R data objects which can store data in more than two dimensions. ➢ It takes vectors as input and uses the values in the dim parameter to create an array. Lists Arrays Matrices vector1 <- c(5,9,3) vector2 <- c(10,11,12,13,14,15) result <- array(c(vector1,vector2),dim = c(3,3,2)) Factors Data Frames https://www.edureka.co/r-for-analytics EDUREKA DATA ANALYTICS WITH R CERTIFICATION TRAINING

  34. Data Type Vectors ➢ Matrices are the R objects in which the elements are arranged in a two- dimensional rectangular layout. ➢ A Matrix is created using the matrix() function. Lists Arrays matrix(data, nrow, ncol, byrow, dimnames) Matrices ❖ 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. Factors Data Frames https://www.edureka.co/r-for-analytics EDUREKA DATA ANALYTICS WITH R CERTIFICATION TRAINING

  35. Data Type Vectors ➢ Factors are the data objects which are used to categorize the data and store it as levels ➢ They can store both strings and integers. ➢ They are useful in data analysis for statistical modeling. Lists Arrays Matrices Factors data <- c("East","West","East","North","North","East","West","West“,"East“) factor_data <- factor(data) Data Frames https://www.edureka.co/r-for-analytics EDUREKA DATA ANALYTICS WITH R CERTIFICATION TRAINING

  36. Data Type Vectors ➢ A 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. Lists Arrays emp_id = c (1:5), Matrices emp_name = c("Rick","Dan","Michelle","Ryan","Gary"), salary = c(623.3,515.2,611.0,729.0,843.25), emp.data <- data.frame(emp_id, emp_name, salary) Factors Data Frames https://www.edureka.co/r-for-analytics EDUREKA DATA ANALYTICS WITH R CERTIFICATION TRAINING

  37. Flow Control Statements https://www.edureka.co/r-for-analytics EDUREKA DATA ANALYTICS WITH R CERTIFICATION TRAINING

  38. Flow Control Statements https://www.edureka.co/r-for-analytics EDUREKA DATA ANALYTICS WITH R CERTIFICATION TRAINING

  39. Fundamental Concepts of R Selection Statements Data Operator Variable Loops Data Types https://www.edureka.co/r-for-analytics EDUREKA DATA ANALYTICS WITH R CERTIFICATION TRAINING

  40. Flow Control SELECTORS CHOOSE ACTIONS SO YOU DON’T HAVE TO ... It evaluates a single condition if It evaluates a group of conditions and selects the statements if .. else It checks the different known possibilities and selects the statements switch https://www.edureka.co/r-for-analytics EDUREKA DATA ANALYTICS WITH R CERTIFICATION TRAINING

  41. Flow Control 1. If statement START Syntax: if (condition): statements 1 … if condition TRUE FALSE Conditional code End https://www.edureka.co/r-for-analytics EDUREKA DATA ANALYTICS WITH R CERTIFICATION TRAINING

  42. Flow Control 2. if…else statement Start Syntax: if (condition 1): statements 1 … . . . else statements n … FALSE If Else If Condition Condition FALSE TRUE TRUE Else code If code Else If code End https://www.edureka.co/r-for-analytics EDUREKA DATA ANALYTICS WITH R CERTIFICATION TRAINING

  43. Flow Control START 3. Switch statement Syntax: Switch switch (expression, value1: Statement1 value2: Statement2 . . , default Statement ) TRUE Case1 Statement1 FALSE TRUE Statement2 Case2 FALSE Default Statement default End https://www.edureka.co/r-for-analytics EDUREKA DATA ANALYTICS WITH R CERTIFICATION TRAINING

  44. Fundamental Concepts of R Conditional Statements Data Operator Variable Data Types Loops https://www.edureka.co/r-for-analytics EDUREKA DATA ANALYTICS WITH R CERTIFICATION TRAINING

  45. Flow Control LOOPS REPEAT ACTIONS SO YOU DON’T HAVE TO ... Repeat things until the loop condition is true Repeat Repeat things until the loop condition is true While Repeat things till the given number of times For https://www.edureka.co/r-for-analytics EDUREKA DATA ANALYTICS WITH R CERTIFICATION TRAINING

  46. Flow Control 4. repeat statement START Syntax: repeat { commands if(condition) { break } } EXECUTE BLOCK repeat TRUE FALSE CHECK CONDITION EXIT LOOP https://www.edureka.co/r-for-analytics EDUREKA DATA ANALYTICS WITH R CERTIFICATION TRAINING

  47. Flow Control 5. while statement START Syntax: while (condition is True) { statements… } FALSE CHECK CONDITION TRUE repeat EXIT LOOP EXECUTE BLOCK https://www.edureka.co/r-for-analytics EDUREKA DATA ANALYTICS WITH R CERTIFICATION TRAINING

  48. Flow Control 6. for statement START Syntax: for(value in vector) { statements… } Initialization FALSE Check condition Exit loop TRUE repeat Execute Statements https://www.edureka.co/r-for-analytics EDUREKA DATA ANALYTICS WITH R CERTIFICATION TRAINING

  49. Flow Control 7. break START Syntax: break; FALSE Check Loop Condition TRUE EXIT LOOP repeat TRUE Check Break Condition FALSE EXIT LOOP Execute Block https://www.edureka.co/r-for-analytics EDUREKA DATA ANALYTICS WITH R CERTIFICATION TRAINING

  50. Flow Control 8. next START Syntax: next; FALSE Check Loop Condition TRUE EXIT LOOP repeat Execute Block 1 Check next Condition TRUE FALSE Execute Block 2 https://www.edureka.co/r-for-analytics EDUREKA DATA ANALYTICS WITH R CERTIFICATION TRAINING

More Related