SlideShare une entreprise Scribd logo
1  sur  27
Introduction to R
Venkat Reddy
•
•
•
•
•
•
•
•

What is R
R basics
Working with R
R packages
R Functions
Importing & Exporting data
Creating calculated fields
R Help & Tutorials

Data Analysis Course
Venkat Reddy

Contents

2
• Programming “environment”
• Runs on a variety of platforms including Windows, Unix and
MacOS.
• Provides an unparalleled platform for programming new
statistical methods in an easy and straightforward manner.
• Object-oriented
• Open source
• Excellent graphics capabilities
• Supported by a large user network

Data Analysis Course
Venkat Reddy

R

3
Downloading

Data Analysis Course
Venkat Reddy

• Google it using R or CRAN (Comprehensive R Archive
Network)
• http://www.r-project.org

4
Data Analysis Course
Venkat Reddy

R

5
Data Analysis Course
Venkat Reddy

R Studio

6
•
•
•
•
•

2+2
log(10)
help(log)
summary(airquality)
demo(graphics) # pretty pictures...

Data Analysis Course
Venkat Reddy

R-Demo

7
R-Basics :Naming convention
• must start with a letter (A-Z or a-z)
• can contain letters, digits (0-9), and/or periods “.”
• mydata different from MyData

Data Analysis Course
Venkat Reddy

• R is a case sensitive language.

8
R-Basics :Assignment
• “<-” used to indicate assignment

• Assignment to an object is denoted by ”<-” or ”->” or ”=”.
• If you see a notation ”= =”, you’ll looking at a comparison
operator.
– Many other notations can be found from the
documentation for the Base package or R.

Data Analysis Course
Venkat Reddy

• x<-c(1,2,3,4,5,6,7)
• x<-c(1:7)
• x<-1:4

9
• during an R session, all objects are stored in a
temporary, working memory
• Commands are entered interactively at the R user prompt. Up
and down arrow keys scroll through your command history.
• list objects ls()
• remove objects rm()
• data()

Data Analysis Course
Venkat Reddy

Workspace

10
•
•
•
•
•
•
•
•
•
•

x <- round(rnorm(10,mean=20,sd=5)) # simulate data
x
mean(x)
m <- mean(x)
m
x- m # notice recycling
(x - m)^2
sum((x - m)^2)
data()
UKgas

Data Analysis Course
Venkat Reddy

Demo: Working with R

11
• R consists of a core and packages. Packages contain functions
that are not available in the core.
• Collections of R functions, data, and compiled code
• Well-defined format that ensures easy installation, a basic
standard of documentation, and enhances portability and
reliability
• When you download R, already a number (around 30) of
packages are downloaded as well.
• You can use the function search to see a list of packages that
are currently attached to the system, this list is also called the
search path.

• search()

Data Analysis Course
Venkat Reddy

R Packages

12
• Select the `Packages' menu and select `Install package...', a list
of available packages on your system will be displayed.
• Select one and click `OK', the package is now attached to your
current R session. Via the library function
• The library can also be used to list all the available libraries on
your system with a short description. Run the function
without any arguments

Data Analysis Course
Venkat Reddy

R packages

13
Demo: R packages

Data Analysis Course
Venkat Reddy

• Install cluster package
• Install plyr package (for string operations)

14
Importing Data
• Reading CSV file
• X <-read.csv(“file.csv")

• reads in data from an external file
• d <- read.table("myfile", header=TRUE)

• R has ODBC for connecting to other programs
• R gets confused if you use a path in your code like
c:mydocumentsmyfile.txt
• This is because R sees "" as an escape character. Instead, use
c:my documentsmyfile.txt
or
c:/mydocuments/myfile.txt

Data Analysis Course
Venkat Reddy

• read.table()

15
Demo: Importing data
• petrol<-read.csv("C:UsersVENKATGoogle
DriveTrainingRDataPetrol_Consuption.csv")
• sales_data<-read.table("C:UsersVENKATGoogle
DriveTrainingRDatasales.txt")
• sales_data<-read.table("C:UsersVENKATGoogle
DriveTrainingRDatasales.txt",header=TRUE)

Data Analysis Course
Venkat Reddy

• Reading CSV file

16
Exporting data
• To A Tab Delimited Text File
• write.table(mydata, "c:/mydata.txt", sep="t")
• library(xlsReadWrite)
• write.xls(mydata, "c:/mydata.xls")

• To SAS
• library(foreign)
• write.foreign(mydata, "c:/mydata.txt", "c:/mydata.sas", package="SAS")

Data Analysis Course
Venkat Reddy

• To an Excel Spreadsheet

17
Demo: Exporting data

Data Analysis Course
Venkat Reddy

• write.table(sales_data, "C:UsersVENKATGoogle
DriveTrainingRDatasales_export.txt", sep="t")
• write.table(sales_data, "C:UsersVENKATGoogle
DriveTrainingRDatasales_export.csv", sep=",")

18
R- Functions
Numeric Functions
Description

abs(x)

absolute value

sqrt(x)

square root

ceiling(x)

ceiling(3.475) is 4

floor(x)

floor(3.475) is 3

trunc(x)

trunc(5.99) is 5

round(x, digits=n)

round(3.475, digits=2) is 3.48

signif(x, digits=n)

signif(3.475, digits=2) is 3.5

cos(x), sin(x), tan(x)

also acos(x), cosh(x), acosh(x), etc.

log(x)

natural logarithm

log10(x)

common logarithm

exp(x)

e^x

Data Analysis Course
Venkat Reddy

Function

19
•
•
•
•

y<-abs(-20)
x<-Sum(y+5)
Z<-Log(x)
round(x,1)

Data Analysis Course
Venkat Reddy

Demo: Numeric Functions

20
Character Functions
Description

substr(x, start=n1, stop=n2)

Extract or replace substrings in a character vector.
x <- "abcdef"
substr(x, 2, 4) is "bcd"
substr(x, 2, 4) <- "22222" is "a222ef"

grep(pattern, x ,
ignore.case=FALSE,
fixed=FALSE)

Search for pattern in x. If fixed =FALSE then pattern is a regular
expression. If fixed=TRUE then pattern is a text string. Returns
matching indices.
grep("A", c("b","A","c"), fixed=TRUE) returns 2

sub(pattern, replacement, x,
ignore.case =FALSE,
fixed=FALSE)

Find pattern in x and replace with replacement text. If fixed=FALSE
then pattern is a regular expression.
If fixed = T then pattern is a text string.
sub("s",".","Hello There") returns "Hello.There"

strsplit(x, split)

Split the elements of character vector x at split.
strsplit("abc", "") returns 3 element vector "a","b","c"

paste(..., sep="")

Concatenate strings after using sep string to seperate them.
paste("x",1:3,sep="") returns c("x1","x2" "x3")
paste("x",1:3,sep="M") returns c("xM1","xM2" "xM3")
paste("Today is", date())

toupper(x)

Uppercase

Data Analysis Course
Venkat Reddy

Function

21
Demo :Character Functions

Data Analysis Course
Venkat Reddy

• cust_id<-"Cust1233416"
• id<-substr(cust_id, 5,10)
• Up=toupper(cust_id)

22
Calculated Fields in R
•
•
•
•
•
•

mydata$sum <- mydata$x1 + mydata$x2
mydata$mean <- (mydata$x1 + mydata$x2)/2
attach(mydata)
mydata$sum <- x1 + x2
mydata$mean <- (x1 + x2)/2
detach(mydata)

Data Analysis Course
Venkat Reddy

• Use the assignment operator <- to create new variables. A
wide array of operators and functions are available here.

23
•
•
•
•
•
•
•
•

sales_data$reduce<-(sales_data$Sales)*0.2
View(sales_data)
sales_data$new_sales<-sales_data$Sales- sales_data$reduce
attach(petrol)
ratio=Income/consum_mill_gallons
View(petrol)
petrol$ratio=Income/Consum_mill_gallons
View(petrol)

Data Analysis Course
Venkat Reddy

Demo Calculated Fields in R

24
• If you encounter a new command during the exercises, and you’d
like to know what it does, please consult the documentation. All R
commands are listed nowhere, and the only way to get to know new
commands is to read the documentation files, so we’d like you to
practise this youself.
• Tutorials
Each of the following tutorials are in PDF format.
• P. Kuhnert & B. Venables, An Introduction to R: Software for Statistical
Modeling & Computing
• J.H. Maindonald, Using R for Data Analysis and Graphics
• B. Muenchen, R for SAS and SPSS Users
• W.J. Owen, The R Guide
• D. Rossiter, Introduction to the R Project for Statistical Computing for
Use at the ITC
• W.N. Venebles & D. M. Smith, An Introduction to R

Data Analysis Course
Venkat Reddy

R-Help

25
R-Tutorials
Paul Geissler's excellent R tutorial
Dave Robert's Excellent Labs on Ecological Analysis
Excellent Tutorials by David Rossitier
Excellent tutorial an nearly every aspect of R (c/o Rob
Kabacoff) MOST of these notes follow this web page format
• Introduction to R by Vincent Zoonekynd
• R Cookbook
• Data Manipulation Reference

Data Analysis Course
Venkat Reddy

•
•
•
•

26
Data Analysis Course
Venkat Reddy

Thank you

27

Contenu connexe

Tendances

Data structures and algorithm analysis in java
Data structures and algorithm analysis in javaData structures and algorithm analysis in java
Data structures and algorithm analysis in javaMuhammad Aleem Siddiqui
 
Session 06 machine learning.pptx
Session 06 machine learning.pptxSession 06 machine learning.pptx
Session 06 machine learning.pptxbodaceacat
 
Introduction of Feature Hashing
Introduction of Feature HashingIntroduction of Feature Hashing
Introduction of Feature HashingWush Wu
 
Analysis of algorithms
Analysis of algorithmsAnalysis of algorithms
Analysis of algorithmsiqbalphy1
 
Generalized Linear Models with H2O
Generalized Linear Models with H2O Generalized Linear Models with H2O
Generalized Linear Models with H2O Sri Ambati
 
K-means Clustering with Scikit-Learn
K-means Clustering with Scikit-LearnK-means Clustering with Scikit-Learn
K-means Clustering with Scikit-LearnSarah Guido
 
Data Structure and Algorithms
Data Structure and AlgorithmsData Structure and Algorithms
Data Structure and Algorithmsiqbalphy1
 
Introduction data structure
Introduction data structureIntroduction data structure
Introduction data structureMuhammad Ismail
 
Feature Engineering - Getting most out of data for predictive models
Feature Engineering - Getting most out of data for predictive modelsFeature Engineering - Getting most out of data for predictive models
Feature Engineering - Getting most out of data for predictive modelsGabriel Moreira
 
Enhancing Spark SQL Optimizer with Reliable Statistics
Enhancing Spark SQL Optimizer with Reliable StatisticsEnhancing Spark SQL Optimizer with Reliable Statistics
Enhancing Spark SQL Optimizer with Reliable StatisticsJen Aman
 
Log Analytics in Datacenter with Apache Spark and Machine Learning
Log Analytics in Datacenter with Apache Spark and Machine LearningLog Analytics in Datacenter with Apache Spark and Machine Learning
Log Analytics in Datacenter with Apache Spark and Machine LearningPiotr Tylenda
 
Branch And Bound and Beam Search Feature Selection Algorithms
Branch And Bound and Beam Search Feature Selection AlgorithmsBranch And Bound and Beam Search Feature Selection Algorithms
Branch And Bound and Beam Search Feature Selection AlgorithmsChamin Nalinda Loku Gam Hewage
 
Building Random Forest at Scale
Building Random Forest at ScaleBuilding Random Forest at Scale
Building Random Forest at ScaleSri Ambati
 
Random forest using apache mahout
Random forest using apache mahoutRandom forest using apache mahout
Random forest using apache mahoutGaurav Kasliwal
 
Kaggle Higgs Boson Machine Learning Challenge
Kaggle Higgs Boson Machine Learning ChallengeKaggle Higgs Boson Machine Learning Challenge
Kaggle Higgs Boson Machine Learning ChallengeBernard Ong
 

Tendances (20)

Data structures and algorithm analysis in java
Data structures and algorithm analysis in javaData structures and algorithm analysis in java
Data structures and algorithm analysis in java
 
Session 06 machine learning.pptx
Session 06 machine learning.pptxSession 06 machine learning.pptx
Session 06 machine learning.pptx
 
Introduction of Feature Hashing
Introduction of Feature HashingIntroduction of Feature Hashing
Introduction of Feature Hashing
 
Analysis of algorithms
Analysis of algorithmsAnalysis of algorithms
Analysis of algorithms
 
QBIC
QBICQBIC
QBIC
 
Generalized Linear Models with H2O
Generalized Linear Models with H2O Generalized Linear Models with H2O
Generalized Linear Models with H2O
 
K-means Clustering with Scikit-Learn
K-means Clustering with Scikit-LearnK-means Clustering with Scikit-Learn
K-means Clustering with Scikit-Learn
 
Data Structure and Algorithms
Data Structure and AlgorithmsData Structure and Algorithms
Data Structure and Algorithms
 
Introduction data structure
Introduction data structureIntroduction data structure
Introduction data structure
 
Feature Engineering - Getting most out of data for predictive models
Feature Engineering - Getting most out of data for predictive modelsFeature Engineering - Getting most out of data for predictive models
Feature Engineering - Getting most out of data for predictive models
 
Chapter15
Chapter15Chapter15
Chapter15
 
Enhancing Spark SQL Optimizer with Reliable Statistics
Enhancing Spark SQL Optimizer with Reliable StatisticsEnhancing Spark SQL Optimizer with Reliable Statistics
Enhancing Spark SQL Optimizer with Reliable Statistics
 
Log Analytics in Datacenter with Apache Spark and Machine Learning
Log Analytics in Datacenter with Apache Spark and Machine LearningLog Analytics in Datacenter with Apache Spark and Machine Learning
Log Analytics in Datacenter with Apache Spark and Machine Learning
 
Ppt shuai
Ppt shuaiPpt shuai
Ppt shuai
 
Query compiler
Query compilerQuery compiler
Query compiler
 
Branch And Bound and Beam Search Feature Selection Algorithms
Branch And Bound and Beam Search Feature Selection AlgorithmsBranch And Bound and Beam Search Feature Selection Algorithms
Branch And Bound and Beam Search Feature Selection Algorithms
 
Building Random Forest at Scale
Building Random Forest at ScaleBuilding Random Forest at Scale
Building Random Forest at Scale
 
Random forest using apache mahout
Random forest using apache mahoutRandom forest using apache mahout
Random forest using apache mahout
 
Kaggle Higgs Boson Machine Learning Challenge
Kaggle Higgs Boson Machine Learning ChallengeKaggle Higgs Boson Machine Learning Challenge
Kaggle Higgs Boson Machine Learning Challenge
 
Ml7 bagging
Ml7 baggingMl7 bagging
Ml7 bagging
 

En vedette

Introduction to predictive modeling v1
Introduction to predictive modeling v1Introduction to predictive modeling v1
Introduction to predictive modeling v1Venkata Reddy Konasani
 
Model building in credit card and loan approval
Model building in credit card and loan approval Model building in credit card and loan approval
Model building in credit card and loan approval Venkata Reddy Konasani
 
Learning Tableau - Data, Graphs, Filters, Dashboards and Advanced features
Learning Tableau -  Data, Graphs, Filters, Dashboards and Advanced featuresLearning Tableau -  Data, Graphs, Filters, Dashboards and Advanced features
Learning Tableau - Data, Graphs, Filters, Dashboards and Advanced featuresVenkata Reddy Konasani
 
Current Expected Credit Loss Model Presentation
Current Expected Credit Loss Model PresentationCurrent Expected Credit Loss Model Presentation
Current Expected Credit Loss Model PresentationKristina Caltagirone
 
Application layer chapter-9
Application layer chapter-9Application layer chapter-9
Application layer chapter-9Student
 
¿Qué debemos hacer desde Tecnología para estar alineados con la Transformac...
¿Qué debemos hacer desde Tecnología para estar alineados con la Transformac...¿Qué debemos hacer desde Tecnología para estar alineados con la Transformac...
¿Qué debemos hacer desde Tecnología para estar alineados con la Transformac...Martín Cabrera
 
Transformación digital y el nuevo paradigma de TI
Transformación digital y el nuevo paradigma de TI Transformación digital y el nuevo paradigma de TI
Transformación digital y el nuevo paradigma de TI Software Guru
 
Understanding and Predicting Ultimate Loss-Given-Default on Bonds and Loans
Understanding and Predicting Ultimate Loss-Given-Default on Bonds and LoansUnderstanding and Predicting Ultimate Loss-Given-Default on Bonds and Loans
Understanding and Predicting Ultimate Loss-Given-Default on Bonds and LoansMichael Jacobs, Jr.
 

En vedette (20)

Decision tree
Decision treeDecision tree
Decision tree
 
Introduction to predictive modeling v1
Introduction to predictive modeling v1Introduction to predictive modeling v1
Introduction to predictive modeling v1
 
Credit Risk Model Building Steps
Credit Risk Model Building StepsCredit Risk Model Building Steps
Credit Risk Model Building Steps
 
Testing of hypothesis case study
Testing of hypothesis case study Testing of hypothesis case study
Testing of hypothesis case study
 
Model building in credit card and loan approval
Model building in credit card and loan approval Model building in credit card and loan approval
Model building in credit card and loan approval
 
Learning Tableau - Data, Graphs, Filters, Dashboards and Advanced features
Learning Tableau -  Data, Graphs, Filters, Dashboards and Advanced featuresLearning Tableau -  Data, Graphs, Filters, Dashboards and Advanced features
Learning Tableau - Data, Graphs, Filters, Dashboards and Advanced features
 
Machine Learning for Dummies
Machine Learning for DummiesMachine Learning for Dummies
Machine Learning for Dummies
 
Estadística con Lenguaje R: Sesión 2
Estadística con Lenguaje R: Sesión 2Estadística con Lenguaje R: Sesión 2
Estadística con Lenguaje R: Sesión 2
 
Estadística con Lenguaje R: Sesión 3
Estadística con Lenguaje R: Sesión 3Estadística con Lenguaje R: Sesión 3
Estadística con Lenguaje R: Sesión 3
 
Estadística con Lenguaje R: Sesión 1
Estadística con Lenguaje R: Sesión 1Estadística con Lenguaje R: Sesión 1
Estadística con Lenguaje R: Sesión 1
 
Transformación digital en cifras
Transformación digital en cifrasTransformación digital en cifras
Transformación digital en cifras
 
Estadística con Lenguaje R: Sesión 7
Estadística con Lenguaje R: Sesión 7Estadística con Lenguaje R: Sesión 7
Estadística con Lenguaje R: Sesión 7
 
Estadística con Lenguaje R: Sesión 5
Estadística con Lenguaje R: Sesión 5Estadística con Lenguaje R: Sesión 5
Estadística con Lenguaje R: Sesión 5
 
Current Expected Credit Loss Model Presentation
Current Expected Credit Loss Model PresentationCurrent Expected Credit Loss Model Presentation
Current Expected Credit Loss Model Presentation
 
Application layer chapter-9
Application layer chapter-9Application layer chapter-9
Application layer chapter-9
 
Estadística con Lenguaje R: Sesión 4
Estadística con Lenguaje R: Sesión 4Estadística con Lenguaje R: Sesión 4
Estadística con Lenguaje R: Sesión 4
 
Estadística con Lenguaje R: Sesión 8
Estadística con Lenguaje R: Sesión 8Estadística con Lenguaje R: Sesión 8
Estadística con Lenguaje R: Sesión 8
 
¿Qué debemos hacer desde Tecnología para estar alineados con la Transformac...
¿Qué debemos hacer desde Tecnología para estar alineados con la Transformac...¿Qué debemos hacer desde Tecnología para estar alineados con la Transformac...
¿Qué debemos hacer desde Tecnología para estar alineados con la Transformac...
 
Transformación digital y el nuevo paradigma de TI
Transformación digital y el nuevo paradigma de TI Transformación digital y el nuevo paradigma de TI
Transformación digital y el nuevo paradigma de TI
 
Understanding and Predicting Ultimate Loss-Given-Default on Bonds and Loans
Understanding and Predicting Ultimate Loss-Given-Default on Bonds and LoansUnderstanding and Predicting Ultimate Loss-Given-Default on Bonds and Loans
Understanding and Predicting Ultimate Loss-Given-Default on Bonds and Loans
 

Similaire à R- Introduction

Slides on introduction to R by ArinBasu MD
Slides on introduction to R by ArinBasu MDSlides on introduction to R by ArinBasu MD
Slides on introduction to R by ArinBasu MDSonaCharles2
 
R - Get Started I - Sanaitics
R - Get Started I - SanaiticsR - Get Started I - Sanaitics
R - Get Started I - SanaiticsVijith Nair
 
AI與大數據數據處理 Spark實戰(20171216)
AI與大數據數據處理 Spark實戰(20171216)AI與大數據數據處理 Spark實戰(20171216)
AI與大數據數據處理 Spark實戰(20171216)Paul Chao
 
Intro to R statistic programming
Intro to R statistic programming Intro to R statistic programming
Intro to R statistic programming Bryan Downing
 
How to obtain and install R.ppt
How to obtain and install R.pptHow to obtain and install R.ppt
How to obtain and install R.pptrajalakshmi5921
 
Introduction to R - from Rstudio to ggplot
Introduction to R - from Rstudio to ggplotIntroduction to R - from Rstudio to ggplot
Introduction to R - from Rstudio to ggplotOlga Scrivner
 
Big Data Day LA 2015 - Scalable and High-Performance Analytics with Distribut...
Big Data Day LA 2015 - Scalable and High-Performance Analytics with Distribut...Big Data Day LA 2015 - Scalable and High-Performance Analytics with Distribut...
Big Data Day LA 2015 - Scalable and High-Performance Analytics with Distribut...Data Con LA
 
6 tips for improving ruby performance
6 tips for improving ruby performance6 tips for improving ruby performance
6 tips for improving ruby performanceEngine Yard
 
A Workshop on R
A Workshop on RA Workshop on R
A Workshop on RAjay Ohri
 
Advanced Data Analytics with R Programming.ppt
Advanced Data Analytics with R Programming.pptAdvanced Data Analytics with R Programming.ppt
Advanced Data Analytics with R Programming.pptAnshika865276
 
Hadoop and HBase experiences in perf log project
Hadoop and HBase experiences in perf log projectHadoop and HBase experiences in perf log project
Hadoop and HBase experiences in perf log projectMao Geng
 
BUSINESS ANALYTICS WITH R SOFTWARE DIAST
BUSINESS ANALYTICS WITH R SOFTWARE DIASTBUSINESS ANALYTICS WITH R SOFTWARE DIAST
BUSINESS ANALYTICS WITH R SOFTWARE DIASTHaritikaChhatwal1
 
Conference 2014: Rajat Arya - Deployment with GraphLab Create
Conference 2014: Rajat Arya - Deployment with GraphLab Create Conference 2014: Rajat Arya - Deployment with GraphLab Create
Conference 2014: Rajat Arya - Deployment with GraphLab Create Turi, Inc.
 
PostgreSQL Performance Problems: Monitoring and Alerting
PostgreSQL Performance Problems: Monitoring and AlertingPostgreSQL Performance Problems: Monitoring and Alerting
PostgreSQL Performance Problems: Monitoring and AlertingGrant Fritchey
 

Similaire à R- Introduction (20)

17641.ppt
17641.ppt17641.ppt
17641.ppt
 
Slides on introduction to R by ArinBasu MD
Slides on introduction to R by ArinBasu MDSlides on introduction to R by ArinBasu MD
Slides on introduction to R by ArinBasu MD
 
17641.ppt
17641.ppt17641.ppt
17641.ppt
 
R - Get Started I - Sanaitics
R - Get Started I - SanaiticsR - Get Started I - Sanaitics
R - Get Started I - Sanaitics
 
AI與大數據數據處理 Spark實戰(20171216)
AI與大數據數據處理 Spark實戰(20171216)AI與大數據數據處理 Spark實戰(20171216)
AI與大數據數據處理 Spark實戰(20171216)
 
Intro to R statistic programming
Intro to R statistic programming Intro to R statistic programming
Intro to R statistic programming
 
How to obtain and install R.ppt
How to obtain and install R.pptHow to obtain and install R.ppt
How to obtain and install R.ppt
 
Introduction to R - from Rstudio to ggplot
Introduction to R - from Rstudio to ggplotIntroduction to R - from Rstudio to ggplot
Introduction to R - from Rstudio to ggplot
 
Big Data Day LA 2015 - Scalable and High-Performance Analytics with Distribut...
Big Data Day LA 2015 - Scalable and High-Performance Analytics with Distribut...Big Data Day LA 2015 - Scalable and High-Performance Analytics with Distribut...
Big Data Day LA 2015 - Scalable and High-Performance Analytics with Distribut...
 
6 tips for improving ruby performance
6 tips for improving ruby performance6 tips for improving ruby performance
6 tips for improving ruby performance
 
A Workshop on R
A Workshop on RA Workshop on R
A Workshop on R
 
Getting Started with R
Getting Started with RGetting Started with R
Getting Started with R
 
Devtools cheatsheet
Devtools cheatsheetDevtools cheatsheet
Devtools cheatsheet
 
Devtools cheatsheet
Devtools cheatsheetDevtools cheatsheet
Devtools cheatsheet
 
Advanced Data Analytics with R Programming.ppt
Advanced Data Analytics with R Programming.pptAdvanced Data Analytics with R Programming.ppt
Advanced Data Analytics with R Programming.ppt
 
Data Exploration in R.pptx
Data Exploration in R.pptxData Exploration in R.pptx
Data Exploration in R.pptx
 
Hadoop and HBase experiences in perf log project
Hadoop and HBase experiences in perf log projectHadoop and HBase experiences in perf log project
Hadoop and HBase experiences in perf log project
 
BUSINESS ANALYTICS WITH R SOFTWARE DIAST
BUSINESS ANALYTICS WITH R SOFTWARE DIASTBUSINESS ANALYTICS WITH R SOFTWARE DIAST
BUSINESS ANALYTICS WITH R SOFTWARE DIAST
 
Conference 2014: Rajat Arya - Deployment with GraphLab Create
Conference 2014: Rajat Arya - Deployment with GraphLab Create Conference 2014: Rajat Arya - Deployment with GraphLab Create
Conference 2014: Rajat Arya - Deployment with GraphLab Create
 
PostgreSQL Performance Problems: Monitoring and Alerting
PostgreSQL Performance Problems: Monitoring and AlertingPostgreSQL Performance Problems: Monitoring and Alerting
PostgreSQL Performance Problems: Monitoring and Alerting
 

Plus de Venkata Reddy Konasani

Machine Learning Deep Learning AI and Data Science
Machine Learning Deep Learning AI and Data Science Machine Learning Deep Learning AI and Data Science
Machine Learning Deep Learning AI and Data Science Venkata Reddy Konasani
 
Model selection and cross validation techniques
Model selection and cross validation techniquesModel selection and cross validation techniques
Model selection and cross validation techniquesVenkata Reddy Konasani
 
Table of Contents - Practical Business Analytics using SAS
Table of Contents - Practical Business Analytics using SAS Table of Contents - Practical Business Analytics using SAS
Table of Contents - Practical Business Analytics using SAS Venkata Reddy Konasani
 
Data Exploration, Validation and Sanitization
Data Exploration, Validation and SanitizationData Exploration, Validation and Sanitization
Data Exploration, Validation and SanitizationVenkata Reddy Konasani
 

Plus de Venkata Reddy Konasani (19)

Transformers 101
Transformers 101 Transformers 101
Transformers 101
 
Machine Learning Deep Learning AI and Data Science
Machine Learning Deep Learning AI and Data Science Machine Learning Deep Learning AI and Data Science
Machine Learning Deep Learning AI and Data Science
 
Model selection and cross validation techniques
Model selection and cross validation techniquesModel selection and cross validation techniques
Model selection and cross validation techniques
 
Neural Network Part-2
Neural Network Part-2Neural Network Part-2
Neural Network Part-2
 
GBM theory code and parameters
GBM theory code and parametersGBM theory code and parameters
GBM theory code and parameters
 
Table of Contents - Practical Business Analytics using SAS
Table of Contents - Practical Business Analytics using SAS Table of Contents - Practical Business Analytics using SAS
Table of Contents - Practical Business Analytics using SAS
 
SAS basics Step by step learning
SAS basics Step by step learningSAS basics Step by step learning
SAS basics Step by step learning
 
L101 predictive modeling case_study
L101 predictive modeling case_studyL101 predictive modeling case_study
L101 predictive modeling case_study
 
Online data sources for analaysis
Online data sources for analaysis Online data sources for analaysis
Online data sources for analaysis
 
A data analyst view of Bigdata
A data analyst view of Bigdata A data analyst view of Bigdata
A data analyst view of Bigdata
 
ARIMA
ARIMA ARIMA
ARIMA
 
Big data Introduction by Mohan
Big data Introduction by MohanBig data Introduction by Mohan
Big data Introduction by Mohan
 
Data Analyst - Interview Guide
Data Analyst - Interview GuideData Analyst - Interview Guide
Data Analyst - Interview Guide
 
Testing of hypothesis
Testing of hypothesisTesting of hypothesis
Testing of hypothesis
 
Multiple regression
Multiple regressionMultiple regression
Multiple regression
 
Logistic regression
Logistic regressionLogistic regression
Logistic regression
 
Statistical Distributions
Statistical DistributionsStatistical Distributions
Statistical Distributions
 
Descriptive statistics
Descriptive statisticsDescriptive statistics
Descriptive statistics
 
Data Exploration, Validation and Sanitization
Data Exploration, Validation and SanitizationData Exploration, Validation and Sanitization
Data Exploration, Validation and Sanitization
 

Dernier

ROLES IN A STAGE PRODUCTION in arts.pptx
ROLES IN A STAGE PRODUCTION in arts.pptxROLES IN A STAGE PRODUCTION in arts.pptx
ROLES IN A STAGE PRODUCTION in arts.pptxVanesaIglesias10
 
Incoming and Outgoing Shipments in 3 STEPS Using Odoo 17
Incoming and Outgoing Shipments in 3 STEPS Using Odoo 17Incoming and Outgoing Shipments in 3 STEPS Using Odoo 17
Incoming and Outgoing Shipments in 3 STEPS Using Odoo 17Celine George
 
How to Add Barcode on PDF Report in Odoo 17
How to Add Barcode on PDF Report in Odoo 17How to Add Barcode on PDF Report in Odoo 17
How to Add Barcode on PDF Report in Odoo 17Celine George
 
Keynote by Prof. Wurzer at Nordex about IP-design
Keynote by Prof. Wurzer at Nordex about IP-designKeynote by Prof. Wurzer at Nordex about IP-design
Keynote by Prof. Wurzer at Nordex about IP-designMIPLM
 
HỌC TỐT TIẾNG ANH 11 THEO CHƯƠNG TRÌNH GLOBAL SUCCESS ĐÁP ÁN CHI TIẾT - CẢ NĂ...
HỌC TỐT TIẾNG ANH 11 THEO CHƯƠNG TRÌNH GLOBAL SUCCESS ĐÁP ÁN CHI TIẾT - CẢ NĂ...HỌC TỐT TIẾNG ANH 11 THEO CHƯƠNG TRÌNH GLOBAL SUCCESS ĐÁP ÁN CHI TIẾT - CẢ NĂ...
HỌC TỐT TIẾNG ANH 11 THEO CHƯƠNG TRÌNH GLOBAL SUCCESS ĐÁP ÁN CHI TIẾT - CẢ NĂ...Nguyen Thanh Tu Collection
 
ClimART Action | eTwinning Project
ClimART Action    |    eTwinning ProjectClimART Action    |    eTwinning Project
ClimART Action | eTwinning Projectjordimapav
 
Virtual-Orientation-on-the-Administration-of-NATG12-NATG6-and-ELLNA.pdf
Virtual-Orientation-on-the-Administration-of-NATG12-NATG6-and-ELLNA.pdfVirtual-Orientation-on-the-Administration-of-NATG12-NATG6-and-ELLNA.pdf
Virtual-Orientation-on-the-Administration-of-NATG12-NATG6-and-ELLNA.pdfErwinPantujan2
 
Activity 2-unit 2-update 2024. English translation
Activity 2-unit 2-update 2024. English translationActivity 2-unit 2-update 2024. English translation
Activity 2-unit 2-update 2024. English translationRosabel UA
 
Presentation Activity 2. Unit 3 transv.pptx
Presentation Activity 2. Unit 3 transv.pptxPresentation Activity 2. Unit 3 transv.pptx
Presentation Activity 2. Unit 3 transv.pptxRosabel UA
 
AUDIENCE THEORY -CULTIVATION THEORY - GERBNER.pptx
AUDIENCE THEORY -CULTIVATION THEORY -  GERBNER.pptxAUDIENCE THEORY -CULTIVATION THEORY -  GERBNER.pptx
AUDIENCE THEORY -CULTIVATION THEORY - GERBNER.pptxiammrhaywood
 
GRADE 4 - SUMMATIVE TEST QUARTER 4 ALL SUBJECTS
GRADE 4 - SUMMATIVE TEST QUARTER 4 ALL SUBJECTSGRADE 4 - SUMMATIVE TEST QUARTER 4 ALL SUBJECTS
GRADE 4 - SUMMATIVE TEST QUARTER 4 ALL SUBJECTSJoshuaGantuangco2
 
Concurrency Control in Database Management system
Concurrency Control in Database Management systemConcurrency Control in Database Management system
Concurrency Control in Database Management systemChristalin Nelson
 
Transaction Management in Database Management System
Transaction Management in Database Management SystemTransaction Management in Database Management System
Transaction Management in Database Management SystemChristalin Nelson
 
Expanded definition: technical and operational
Expanded definition: technical and operationalExpanded definition: technical and operational
Expanded definition: technical and operationalssuser3e220a
 
ANG SEKTOR NG agrikultura.pptx QUARTER 4
ANG SEKTOR NG agrikultura.pptx QUARTER 4ANG SEKTOR NG agrikultura.pptx QUARTER 4
ANG SEKTOR NG agrikultura.pptx QUARTER 4MiaBumagat1
 
Inclusivity Essentials_ Creating Accessible Websites for Nonprofits .pdf
Inclusivity Essentials_ Creating Accessible Websites for Nonprofits .pdfInclusivity Essentials_ Creating Accessible Websites for Nonprofits .pdf
Inclusivity Essentials_ Creating Accessible Websites for Nonprofits .pdfTechSoup
 
INTRODUCTION TO CATHOLIC CHRISTOLOGY.pptx
INTRODUCTION TO CATHOLIC CHRISTOLOGY.pptxINTRODUCTION TO CATHOLIC CHRISTOLOGY.pptx
INTRODUCTION TO CATHOLIC CHRISTOLOGY.pptxHumphrey A Beña
 
MULTIDISCIPLINRY NATURE OF THE ENVIRONMENTAL STUDIES.pptx
MULTIDISCIPLINRY NATURE OF THE ENVIRONMENTAL STUDIES.pptxMULTIDISCIPLINRY NATURE OF THE ENVIRONMENTAL STUDIES.pptx
MULTIDISCIPLINRY NATURE OF THE ENVIRONMENTAL STUDIES.pptxAnupkumar Sharma
 

Dernier (20)

ROLES IN A STAGE PRODUCTION in arts.pptx
ROLES IN A STAGE PRODUCTION in arts.pptxROLES IN A STAGE PRODUCTION in arts.pptx
ROLES IN A STAGE PRODUCTION in arts.pptx
 
Incoming and Outgoing Shipments in 3 STEPS Using Odoo 17
Incoming and Outgoing Shipments in 3 STEPS Using Odoo 17Incoming and Outgoing Shipments in 3 STEPS Using Odoo 17
Incoming and Outgoing Shipments in 3 STEPS Using Odoo 17
 
How to Add Barcode on PDF Report in Odoo 17
How to Add Barcode on PDF Report in Odoo 17How to Add Barcode on PDF Report in Odoo 17
How to Add Barcode on PDF Report in Odoo 17
 
FINALS_OF_LEFT_ON_C'N_EL_DORADO_2024.pptx
FINALS_OF_LEFT_ON_C'N_EL_DORADO_2024.pptxFINALS_OF_LEFT_ON_C'N_EL_DORADO_2024.pptx
FINALS_OF_LEFT_ON_C'N_EL_DORADO_2024.pptx
 
Keynote by Prof. Wurzer at Nordex about IP-design
Keynote by Prof. Wurzer at Nordex about IP-designKeynote by Prof. Wurzer at Nordex about IP-design
Keynote by Prof. Wurzer at Nordex about IP-design
 
LEFT_ON_C'N_ PRELIMS_EL_DORADO_2024.pptx
LEFT_ON_C'N_ PRELIMS_EL_DORADO_2024.pptxLEFT_ON_C'N_ PRELIMS_EL_DORADO_2024.pptx
LEFT_ON_C'N_ PRELIMS_EL_DORADO_2024.pptx
 
HỌC TỐT TIẾNG ANH 11 THEO CHƯƠNG TRÌNH GLOBAL SUCCESS ĐÁP ÁN CHI TIẾT - CẢ NĂ...
HỌC TỐT TIẾNG ANH 11 THEO CHƯƠNG TRÌNH GLOBAL SUCCESS ĐÁP ÁN CHI TIẾT - CẢ NĂ...HỌC TỐT TIẾNG ANH 11 THEO CHƯƠNG TRÌNH GLOBAL SUCCESS ĐÁP ÁN CHI TIẾT - CẢ NĂ...
HỌC TỐT TIẾNG ANH 11 THEO CHƯƠNG TRÌNH GLOBAL SUCCESS ĐÁP ÁN CHI TIẾT - CẢ NĂ...
 
ClimART Action | eTwinning Project
ClimART Action    |    eTwinning ProjectClimART Action    |    eTwinning Project
ClimART Action | eTwinning Project
 
Virtual-Orientation-on-the-Administration-of-NATG12-NATG6-and-ELLNA.pdf
Virtual-Orientation-on-the-Administration-of-NATG12-NATG6-and-ELLNA.pdfVirtual-Orientation-on-the-Administration-of-NATG12-NATG6-and-ELLNA.pdf
Virtual-Orientation-on-the-Administration-of-NATG12-NATG6-and-ELLNA.pdf
 
Activity 2-unit 2-update 2024. English translation
Activity 2-unit 2-update 2024. English translationActivity 2-unit 2-update 2024. English translation
Activity 2-unit 2-update 2024. English translation
 
Presentation Activity 2. Unit 3 transv.pptx
Presentation Activity 2. Unit 3 transv.pptxPresentation Activity 2. Unit 3 transv.pptx
Presentation Activity 2. Unit 3 transv.pptx
 
AUDIENCE THEORY -CULTIVATION THEORY - GERBNER.pptx
AUDIENCE THEORY -CULTIVATION THEORY -  GERBNER.pptxAUDIENCE THEORY -CULTIVATION THEORY -  GERBNER.pptx
AUDIENCE THEORY -CULTIVATION THEORY - GERBNER.pptx
 
GRADE 4 - SUMMATIVE TEST QUARTER 4 ALL SUBJECTS
GRADE 4 - SUMMATIVE TEST QUARTER 4 ALL SUBJECTSGRADE 4 - SUMMATIVE TEST QUARTER 4 ALL SUBJECTS
GRADE 4 - SUMMATIVE TEST QUARTER 4 ALL SUBJECTS
 
Concurrency Control in Database Management system
Concurrency Control in Database Management systemConcurrency Control in Database Management system
Concurrency Control in Database Management system
 
Transaction Management in Database Management System
Transaction Management in Database Management SystemTransaction Management in Database Management System
Transaction Management in Database Management System
 
Expanded definition: technical and operational
Expanded definition: technical and operationalExpanded definition: technical and operational
Expanded definition: technical and operational
 
ANG SEKTOR NG agrikultura.pptx QUARTER 4
ANG SEKTOR NG agrikultura.pptx QUARTER 4ANG SEKTOR NG agrikultura.pptx QUARTER 4
ANG SEKTOR NG agrikultura.pptx QUARTER 4
 
Inclusivity Essentials_ Creating Accessible Websites for Nonprofits .pdf
Inclusivity Essentials_ Creating Accessible Websites for Nonprofits .pdfInclusivity Essentials_ Creating Accessible Websites for Nonprofits .pdf
Inclusivity Essentials_ Creating Accessible Websites for Nonprofits .pdf
 
INTRODUCTION TO CATHOLIC CHRISTOLOGY.pptx
INTRODUCTION TO CATHOLIC CHRISTOLOGY.pptxINTRODUCTION TO CATHOLIC CHRISTOLOGY.pptx
INTRODUCTION TO CATHOLIC CHRISTOLOGY.pptx
 
MULTIDISCIPLINRY NATURE OF THE ENVIRONMENTAL STUDIES.pptx
MULTIDISCIPLINRY NATURE OF THE ENVIRONMENTAL STUDIES.pptxMULTIDISCIPLINRY NATURE OF THE ENVIRONMENTAL STUDIES.pptx
MULTIDISCIPLINRY NATURE OF THE ENVIRONMENTAL STUDIES.pptx
 

R- Introduction

  • 2. • • • • • • • • What is R R basics Working with R R packages R Functions Importing & Exporting data Creating calculated fields R Help & Tutorials Data Analysis Course Venkat Reddy Contents 2
  • 3. • Programming “environment” • Runs on a variety of platforms including Windows, Unix and MacOS. • Provides an unparalleled platform for programming new statistical methods in an easy and straightforward manner. • Object-oriented • Open source • Excellent graphics capabilities • Supported by a large user network Data Analysis Course Venkat Reddy R 3
  • 4. Downloading Data Analysis Course Venkat Reddy • Google it using R or CRAN (Comprehensive R Archive Network) • http://www.r-project.org 4
  • 6. Data Analysis Course Venkat Reddy R Studio 6
  • 7. • • • • • 2+2 log(10) help(log) summary(airquality) demo(graphics) # pretty pictures... Data Analysis Course Venkat Reddy R-Demo 7
  • 8. R-Basics :Naming convention • must start with a letter (A-Z or a-z) • can contain letters, digits (0-9), and/or periods “.” • mydata different from MyData Data Analysis Course Venkat Reddy • R is a case sensitive language. 8
  • 9. R-Basics :Assignment • “<-” used to indicate assignment • Assignment to an object is denoted by ”<-” or ”->” or ”=”. • If you see a notation ”= =”, you’ll looking at a comparison operator. – Many other notations can be found from the documentation for the Base package or R. Data Analysis Course Venkat Reddy • x<-c(1,2,3,4,5,6,7) • x<-c(1:7) • x<-1:4 9
  • 10. • during an R session, all objects are stored in a temporary, working memory • Commands are entered interactively at the R user prompt. Up and down arrow keys scroll through your command history. • list objects ls() • remove objects rm() • data() Data Analysis Course Venkat Reddy Workspace 10
  • 11. • • • • • • • • • • x <- round(rnorm(10,mean=20,sd=5)) # simulate data x mean(x) m <- mean(x) m x- m # notice recycling (x - m)^2 sum((x - m)^2) data() UKgas Data Analysis Course Venkat Reddy Demo: Working with R 11
  • 12. • R consists of a core and packages. Packages contain functions that are not available in the core. • Collections of R functions, data, and compiled code • Well-defined format that ensures easy installation, a basic standard of documentation, and enhances portability and reliability • When you download R, already a number (around 30) of packages are downloaded as well. • You can use the function search to see a list of packages that are currently attached to the system, this list is also called the search path. • search() Data Analysis Course Venkat Reddy R Packages 12
  • 13. • Select the `Packages' menu and select `Install package...', a list of available packages on your system will be displayed. • Select one and click `OK', the package is now attached to your current R session. Via the library function • The library can also be used to list all the available libraries on your system with a short description. Run the function without any arguments Data Analysis Course Venkat Reddy R packages 13
  • 14. Demo: R packages Data Analysis Course Venkat Reddy • Install cluster package • Install plyr package (for string operations) 14
  • 15. Importing Data • Reading CSV file • X <-read.csv(“file.csv") • reads in data from an external file • d <- read.table("myfile", header=TRUE) • R has ODBC for connecting to other programs • R gets confused if you use a path in your code like c:mydocumentsmyfile.txt • This is because R sees "" as an escape character. Instead, use c:my documentsmyfile.txt or c:/mydocuments/myfile.txt Data Analysis Course Venkat Reddy • read.table() 15
  • 16. Demo: Importing data • petrol<-read.csv("C:UsersVENKATGoogle DriveTrainingRDataPetrol_Consuption.csv") • sales_data<-read.table("C:UsersVENKATGoogle DriveTrainingRDatasales.txt") • sales_data<-read.table("C:UsersVENKATGoogle DriveTrainingRDatasales.txt",header=TRUE) Data Analysis Course Venkat Reddy • Reading CSV file 16
  • 17. Exporting data • To A Tab Delimited Text File • write.table(mydata, "c:/mydata.txt", sep="t") • library(xlsReadWrite) • write.xls(mydata, "c:/mydata.xls") • To SAS • library(foreign) • write.foreign(mydata, "c:/mydata.txt", "c:/mydata.sas", package="SAS") Data Analysis Course Venkat Reddy • To an Excel Spreadsheet 17
  • 18. Demo: Exporting data Data Analysis Course Venkat Reddy • write.table(sales_data, "C:UsersVENKATGoogle DriveTrainingRDatasales_export.txt", sep="t") • write.table(sales_data, "C:UsersVENKATGoogle DriveTrainingRDatasales_export.csv", sep=",") 18
  • 19. R- Functions Numeric Functions Description abs(x) absolute value sqrt(x) square root ceiling(x) ceiling(3.475) is 4 floor(x) floor(3.475) is 3 trunc(x) trunc(5.99) is 5 round(x, digits=n) round(3.475, digits=2) is 3.48 signif(x, digits=n) signif(3.475, digits=2) is 3.5 cos(x), sin(x), tan(x) also acos(x), cosh(x), acosh(x), etc. log(x) natural logarithm log10(x) common logarithm exp(x) e^x Data Analysis Course Venkat Reddy Function 19
  • 21. Character Functions Description substr(x, start=n1, stop=n2) Extract or replace substrings in a character vector. x <- "abcdef" substr(x, 2, 4) is "bcd" substr(x, 2, 4) <- "22222" is "a222ef" grep(pattern, x , ignore.case=FALSE, fixed=FALSE) Search for pattern in x. If fixed =FALSE then pattern is a regular expression. If fixed=TRUE then pattern is a text string. Returns matching indices. grep("A", c("b","A","c"), fixed=TRUE) returns 2 sub(pattern, replacement, x, ignore.case =FALSE, fixed=FALSE) Find pattern in x and replace with replacement text. If fixed=FALSE then pattern is a regular expression. If fixed = T then pattern is a text string. sub("s",".","Hello There") returns "Hello.There" strsplit(x, split) Split the elements of character vector x at split. strsplit("abc", "") returns 3 element vector "a","b","c" paste(..., sep="") Concatenate strings after using sep string to seperate them. paste("x",1:3,sep="") returns c("x1","x2" "x3") paste("x",1:3,sep="M") returns c("xM1","xM2" "xM3") paste("Today is", date()) toupper(x) Uppercase Data Analysis Course Venkat Reddy Function 21
  • 22. Demo :Character Functions Data Analysis Course Venkat Reddy • cust_id<-"Cust1233416" • id<-substr(cust_id, 5,10) • Up=toupper(cust_id) 22
  • 23. Calculated Fields in R • • • • • • mydata$sum <- mydata$x1 + mydata$x2 mydata$mean <- (mydata$x1 + mydata$x2)/2 attach(mydata) mydata$sum <- x1 + x2 mydata$mean <- (x1 + x2)/2 detach(mydata) Data Analysis Course Venkat Reddy • Use the assignment operator <- to create new variables. A wide array of operators and functions are available here. 23
  • 25. • If you encounter a new command during the exercises, and you’d like to know what it does, please consult the documentation. All R commands are listed nowhere, and the only way to get to know new commands is to read the documentation files, so we’d like you to practise this youself. • Tutorials Each of the following tutorials are in PDF format. • P. Kuhnert & B. Venables, An Introduction to R: Software for Statistical Modeling & Computing • J.H. Maindonald, Using R for Data Analysis and Graphics • B. Muenchen, R for SAS and SPSS Users • W.J. Owen, The R Guide • D. Rossiter, Introduction to the R Project for Statistical Computing for Use at the ITC • W.N. Venebles & D. M. Smith, An Introduction to R Data Analysis Course Venkat Reddy R-Help 25
  • 26. R-Tutorials Paul Geissler's excellent R tutorial Dave Robert's Excellent Labs on Ecological Analysis Excellent Tutorials by David Rossitier Excellent tutorial an nearly every aspect of R (c/o Rob Kabacoff) MOST of these notes follow this web page format • Introduction to R by Vincent Zoonekynd • R Cookbook • Data Manipulation Reference Data Analysis Course Venkat Reddy • • • • 26
  • 27. Data Analysis Course Venkat Reddy Thank you 27