Presentation is loading. Please wait.

Presentation is loading. Please wait.

Introduction to R Las Vegas 2015 James McCaffrey Microsoft Research, Advanced Development Tuesday, October 27, 2015 2:15 - 3:30 PM devintersection.com.

Similar presentations


Presentation on theme: "Introduction to R Las Vegas 2015 James McCaffrey Microsoft Research, Advanced Development Tuesday, October 27, 2015 2:15 - 3:30 PM devintersection.com."— Presentation transcript:

1 Introduction to R Las Vegas 2015 James McCaffrey Microsoft Research, Advanced Development Tuesday, October 27, 2015 2:15 - 3:30 PM devintersection.com

2 Agenda What is R? Why consider learning R? Three R Development Environments Examples of R vs. C# Summary, Resources, Q&A

3 What is R ? R is a scripting language, plus an interactive shell environment, plus a large library of math functions. R is open source and has strong support from all key industry, research, government, and academia players. devintersection.com

4 What is R - The Hello World of R > setwd("C:\\IntroToR") > > t <- read.table("Income.txt", header=TRUE, sep=",") > > head(t, n=3) Occupation Age Tech Income 1 Developer 28 7 64 2 Developer 41 8 82 3 Developer 33 6 58 > > m <- lm(t$Income ~ (t$Occupation + t$Age + t$Tech)) > > summary(m) Call: lm(formula = t$Income ~ (t$Occupation + t$Age + t$Tech)) Residuals: 1 2 3 4 5 6 7 8 1.3099 1.8196 -3.1295 0.5584 -0.5584 -2.3067 5.0239 -2.7172 Coefficients: Estimate Std. Error t value Pr(>|t|) (Intercept) -3.9883 16.9005 -0.236 0.8286 t$OccupationManager -7.1989 4.9508 -1.454 0.2419 t$OccupationQuality -14.6279 4.2709 -3.425 0.0417 * t$Age 0.8850 0.3152 2.808 0.0674. t$Tech 5.9856 1.2099 4.947 0.0158 * --- Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1 Residual standard error: 4.219 on 3 degrees of freedom Multiple R-squared: 0.9649, Adjusted R-squared: 0.918 F-statistic: 20.6 on 4 and 3 DF, p-value: 0.01611 > devintersection.com

5 Why R? The most common language for Data Science Microsoft acquisition of RevolutionR Microsoft Azure ML and ML Studio Consulting aspect Big Data and little data (and IoT?) Relatively easy to learn* R Consortium devintersection.com

6 Installing the Base R Environment devintersection.com

7

8

9

10

11

12

13

14

15

16

17

18

19

20

21 Launching R – Start Menu (Rgui.exe) devintersection.com

22 Launching R – File Explorer (Rterm.exe) devintersection.com

23 The RStudio Environment devintersection.com

24 The Revolution R (Microsoft) Environment devintersection.com

25 The Revolution R (Microsoft) Environment devintersection.com

26 R vs. C# (the t-Test) devintersection.com

27 R vs. C# (the t-Test) devintersection.com

28 R vs. C# (the t-Test) devintersection.com

29 R vs. C# (LDA Analysis)

30

31

32 R vs. C# (Graphing) devintersection.com

33 Programming using R and OOP # file CarClass.R require("R6") Car <- R6Class("Car", public = list( make = NULL, price = NULL, initialize = function(ma, pr) { self$make <- ma self$price <- pr }, setMake = function(ma) { self$make <- ma }, # setPrice = function(pr) { self$price <- pr }, display = function() { cat("Make = ", self$make, " Price = ", self$price, "\n") } ) > source(“CarClass.R”) > > myCar <- Car$new(“Audi”, 40000) > > myCar$display() Make = Audi Price = 40000 > > myCar$setMake(“BMW”) > myCar$price = 50000 > > print(myCar) Public: display: function initialize : function make: BMW price: 50000 setMake: function >

34 R vs. C# (Packages, Libraries, Scripts) An R package is a collection of file(s) that contain R functions An R library is 1.) R terminology for the location of a package, or 2.) a DLL (on Windows) The install() command installs an R package The library() command loads an R package for use An R script is a set of R commands R has basic control structures (if – else, for, while, repeat) and four different OOP paradigms devintersection.com

35 Alternatives to R MatLab – very pricey Mathematica - pricey SciLab, Octave – open source versions of MatLab SAS – very pricey SPSS (IBM) – very pricey Python – general purpose (with SciPy library) devintersection.com

36 Your Four Possible Roles with R Use R in interactive mode for ad hoc data analysis Act as a data expert to help an R consultant Write R scripts to automate recurring data analysis Write R code to create custom data analysis devintersection.com

37 Summary R is the deeply entrenched default language for “Data Science” RStudio is the most common optional environment Understanding statistics* is the key to R C# is general purpose, R is domain specific Best examples for R are chaotic Web pages devintersection.com

38 Resources McCaffrey, J., “Introduction to R for C# Programmers”, Microsoft MSDN Magazine, July 2015 (vol. 30, no. 7) McCaffrey, J., “Introduction to R for.NET Developers”, Visual Studio Magazine, December 2015 (vol. 25, no. 12) http://cran.r-project.org/ https://www.r-consortium.org/ jammc@microsoft.com devintersection.com

39 Introduction to R Las Vegas 2015 James McCaffrey Microsoft Research, Advanced Development Tuesday, October 27, 2015 2:15 - 3:30 PM devintersection.com Thank You !


Download ppt "Introduction to R Las Vegas 2015 James McCaffrey Microsoft Research, Advanced Development Tuesday, October 27, 2015 2:15 - 3:30 PM devintersection.com."

Similar presentations


Ads by Google