SlideShare une entreprise Scribd logo
1  sur  25
STATISTICAL COMPUTATION
USING R
 Introduction
 R as a statistical software
 Statistical features
 R preliminaries
 Functions in R
 Graphics in R
 Distributions
 Conclusion
 References
Introduction
 programming language and software environment
for statistical computing and graphics.
 S,S PLUS.
 Developed by Ross Ihaka and Robert Gentleman at
the University of Auckland, New Zealand.
 Open source software
 R works fundamentally by the question-and-answer
model
 Can be downloaded from http://R-Project.org
R - as a Statistical software
 It has very good computing performance
 R makes its view especially in colleges &
universities
 It has excellent built in help system
 Its graphical environment is flexible and
powerful
 Easy for new user
 Easy to extend with user written functions
 It provides scripting and interacting facilities
 Vectors as the basic data structure
Statistical features
 R is an interpreted language
 users typically access it through a command-line
interpreter
 Like other similar languages such as APL and
MATLAB, R supports matrix arithmetic
 R's data structures include vectors, matrices, arrays,
data frames (similar to tables in a relational
database) and lists.
 R supports procedural programming with functions
and, for some functions, object-oriented
programming with generic functions.
R-Preliminaries
Common operators:
 Arithmatic Operator
+ Addition
- Subtract
* Multiplication
/ Division
^ Exponential
 Relational Operator
< Lessthan
> Greaterthan
<= Lessthan Equal
>= Greaterthan Equal
== Is Equal to
!= Not Equal
 Logical Operator
! NOT
& AND
| OR
 Assignment Operator
<- Left assignment
-> Right assignment
Eg : x<-2 Assigns the value 2 to the object x
x^2->y Assigns the value x^2 to the object y
Commands will be lines, starting with a # mark.
To display the value of y, we type ‘print(y)’ or ‘y’
Functions
 function name is followed by a set of parentheses
containing one or more arguments.
Eg: plot(height,weight)
 the function name is ‘plot’ and the arguments are
‘height’ and weight.
 positional matching
Method of data input
 C function (concatenate)
Eg: > x <- c(1, 2, 3)
> y <- c(10, 20)
> c(x, y, 5) # R command
[1] 1 2 3 10 20 5
 Sequence function
seq (“sequence”), is used for equidistant series of
numbers.
Eg: > seq(4,9) # R command
[1] 4 5 6 7 8 9
 If you want a sequence in jumps of 2
Eg: > seq(4,10,2)
[1] 4 6 8 10
Sequence operator “:”
> 4:9 # R command
[1] 4 5 6 7 8 9
 Scan function
Used to provide small quantities of data.
variable=scan() # R command
Used for creating data object
Eg: wt=Scan(103,102,108);
[1] 103 102 108
 Rep function
rep (“replicate”), is used to generate repeated
values
y=rep(x,n) # R command
X<-c(rep(1,4),rep(2,2));
 Data frames
o provides the table of data in R
object=data.frame(list of variables); # R command
o Display the content of data frame with row no.
o Column headings can be modified after creation of
frame.
o Colnames(name of data frame)= c(list of column under
double quotes)
Eg:
n<-c(2, 3, 5)
s<-c("aa", "bb", "cc")
b<-c(TRUE, FALSE,TRUE)
df<-data.frame(n, s, b)
df
o/p
n s b
2 aa TRUE
3 bb FALSE
5 cc TRUE
 Matrix function
> x <- 1:12
> dim(x) <- c(3,4)
> x
[,1] [,2] [,3] [,4]
[1,] 1 4 7 10
[2,] 2 5 8 11
[3,] 3 6 9 12
o The dim assignment function sets or changes the dimension
attribute of x, causing R to treat the vector of 12 numbers as a
3 × 4 matrix
o storage is column-major; that is, the elements of the first
column are followed by those of the second, etc.
o Convenient function to provide matrix type data.
o Another function used to create a data frame.
Object=matrix(c(data values) nrow=m,byrow=T/F)
o The byrow=T switch causes the matrix to be filled in a row
wise fashion rather than column wise
 List function
It is sometimes useful to combine a collection of
objects into a larger composite object.This can be
done using lists.
Eg: > list1 <- c(5640,6180,6390,6805,7515)
list2 <- c(3910,3885,5160,5645,7335)
> mylist <- list(before=list1,after=list2)
>mylist
$before
[1] 5640 6180 6390 6515 6805 7515
$after
[1] 3910 3885 5160 5645 7335
 Class function
used to decide the class of the data object
Eg: > a1<-c(‘x’,’y’);
class(a1);
o/p: character
 Built in functions
length() no. of elements of data
max()the maximum element of data
min() the minimum element of data
sort() sorting in increasing magnitude
-sort() “ decreasing “ etc
Graphics in R
 2 types of graphics function
o High level function, which creates a new graph
o Low level function, which adds elements to an already
existing graph
High level ploting functions
plot() Scatter plot
hist() Histogram
boxplot() box & whisker
barplot() bar diagram
Arguments to plot function
Argument explanation
Main= Tittle
Xlab= Label of X axis
Ylab Label of Y axis
Xlim= Specific X limit
Ylim= “ Y limit
Type= type of ‘p’ for points
Pch= Style of points(bw 0&20)
Col= colour
Low level ploting functions
Lines() Draw lines
abline() Lines given by intercept and slopes
points() Points
text() Texts in the plot
legent() List of symbols
 > age<-c(5,10,15,20)
 > freq<-c(10,15,30,20)
>plot(age,freq,xlab=age,ylab=freq,pch=1,col="b
lue",main="age vs frequency")
Probability Distributions
Distribution Rname Additional Argument
Binomial binom size,probability
Poisson pois lamda
Geometric geom probability
Hyper geom hyper m,n,k
Normal norm mean,sd
Uniform unif min,max
Gamma gamma shape,scale
Chi-square chisq df,df2,nCp
F p df1,df2,nCp
 Binomial Distribution
> n<-10
> p<-.5
> pr<dbinom(x,n,p)# for pmf (pbinom for pdf)
Error: object 'pr' not found
> pr<-dbinom(x,n,p)
> pr
[1] 0.009765625 0.117187500 0.246093750 0.009765625
> pmf<-data.frame(x,pr)
> pmf
x pr
1 1 0.009765625
2 3 0.117187500
3 5 0.246093750
4 9 0.009765625
>
plot(x,pr,type="h",main="binomial",lwd=2,xlab="x",ylab="pr")
Conclusion
 R is a flexible programming language designed to facilitate
exploratory data analysis, classical statistical tests, and high-
level graphics.
 R is a full-fledged programming language, with a rich
complement of mathematical functions, matrix operations and
control structures.
 With its rich and ever-expanding library of packages, R is on the
leading edge of development in statistics, data analytics, and
data mining.
 R has proven itself a useful tool within the growing field of big
data and has been integrated into several commercial packages,
such as IBM SPSS and InfoSphere, as well as Mathematica.
References
 Introductory Statistics with R- Peter
Dalgaard(2nd edition)
 Statistical Computing with R- Eric Slud
 Quick-R : Creating Graphs
http://www.statmethods.net/graphs/
Shoot your queries….?
Thank you

Contenu connexe

Tendances

Introduction to STATA(2).pdf
Introduction to STATA(2).pdfIntroduction to STATA(2).pdf
Introduction to STATA(2).pdf
Yomif3
 

Tendances (20)

Basics of Regression analysis
 Basics of Regression analysis Basics of Regression analysis
Basics of Regression analysis
 
Regression analysis
Regression analysisRegression analysis
Regression analysis
 
Machine Learning in R
Machine Learning in RMachine Learning in R
Machine Learning in R
 
Introduction to STATA(2).pdf
Introduction to STATA(2).pdfIntroduction to STATA(2).pdf
Introduction to STATA(2).pdf
 
Multiple linear regression
Multiple linear regressionMultiple linear regression
Multiple linear regression
 
Multivariate Data Analysis
Multivariate Data AnalysisMultivariate Data Analysis
Multivariate Data Analysis
 
Multivariate analysis
Multivariate analysisMultivariate analysis
Multivariate analysis
 
Regression (Linear Regression and Logistic Regression) by Akanksha Bali
Regression (Linear Regression and Logistic Regression) by Akanksha BaliRegression (Linear Regression and Logistic Regression) by Akanksha Bali
Regression (Linear Regression and Logistic Regression) by Akanksha Bali
 
Overview of Multivariate Statistical Methods
Overview of Multivariate Statistical MethodsOverview of Multivariate Statistical Methods
Overview of Multivariate Statistical Methods
 
Data Analysis with R (combined slides)
Data Analysis with R (combined slides)Data Analysis with R (combined slides)
Data Analysis with R (combined slides)
 
Statistics For Data Science | Statistics Using R Programming Language | Hypot...
Statistics For Data Science | Statistics Using R Programming Language | Hypot...Statistics For Data Science | Statistics Using R Programming Language | Hypot...
Statistics For Data Science | Statistics Using R Programming Language | Hypot...
 
Intro databases (Table, Record, Field)
Intro databases (Table, Record, Field)Intro databases (Table, Record, Field)
Intro databases (Table, Record, Field)
 
4 Descriptive Statistics with R
4 Descriptive Statistics with R4 Descriptive Statistics with R
4 Descriptive Statistics with R
 
Applied Statistical Methods - Question & Answer on SPSS
Applied Statistical Methods - Question & Answer on SPSSApplied Statistical Methods - Question & Answer on SPSS
Applied Statistical Methods - Question & Answer on SPSS
 
R programming language
R programming languageR programming language
R programming language
 
Introduction to R Graphics with ggplot2
Introduction to R Graphics with ggplot2Introduction to R Graphics with ggplot2
Introduction to R Graphics with ggplot2
 
Elmasri Navathe DBMS Unit-1 ppt
Elmasri Navathe DBMS Unit-1 pptElmasri Navathe DBMS Unit-1 ppt
Elmasri Navathe DBMS Unit-1 ppt
 
Data tidying with tidyr meetup
Data tidying with tidyr  meetupData tidying with tidyr  meetup
Data tidying with tidyr meetup
 
Linear regression
Linear regressionLinear regression
Linear regression
 
Stata tutorial
Stata tutorialStata tutorial
Stata tutorial
 

En vedette

Introduction to data structures and Algorithm
Introduction to data structures and AlgorithmIntroduction to data structures and Algorithm
Introduction to data structures and Algorithm
Dhaval Kaneria
 
Back to the Future (evolving model of communication agencies and content in t...
Back to the Future (evolving model of communication agencies and content in t...Back to the Future (evolving model of communication agencies and content in t...
Back to the Future (evolving model of communication agencies and content in t...
Jimmy Ghazal
 

En vedette (9)

statistical computation using R- report
statistical computation using R- reportstatistical computation using R- report
statistical computation using R- report
 
R seminar dplyr package
R seminar dplyr packageR seminar dplyr package
R seminar dplyr package
 
Why R? A Brief Introduction to the Open Source Statistics Platform
Why R? A Brief Introduction to the Open Source Statistics PlatformWhy R? A Brief Introduction to the Open Source Statistics Platform
Why R? A Brief Introduction to the Open Source Statistics Platform
 
Introduction to R Programming
Introduction to R ProgrammingIntroduction to R Programming
Introduction to R Programming
 
R language tutorial
R language tutorialR language tutorial
R language tutorial
 
Class ppt intro to r
Class ppt intro to rClass ppt intro to r
Class ppt intro to r
 
R programming
R programmingR programming
R programming
 
Introduction to data structures and Algorithm
Introduction to data structures and AlgorithmIntroduction to data structures and Algorithm
Introduction to data structures and Algorithm
 
Back to the Future (evolving model of communication agencies and content in t...
Back to the Future (evolving model of communication agencies and content in t...Back to the Future (evolving model of communication agencies and content in t...
Back to the Future (evolving model of communication agencies and content in t...
 

Similaire à statistical computation using R- an intro..

Similaire à statistical computation using R- an intro.. (20)

R Language Introduction
R Language IntroductionR Language Introduction
R Language Introduction
 
Introduction to r
Introduction to rIntroduction to r
Introduction to r
 
R Basics
R BasicsR Basics
R Basics
 
R tutorial for a windows environment
R tutorial for a windows environmentR tutorial for a windows environment
R tutorial for a windows environment
 
R language introduction
R language introductionR language introduction
R language introduction
 
Introduction to matlab
Introduction to matlabIntroduction to matlab
Introduction to matlab
 
R교육1
R교육1R교육1
R교육1
 
R Programming Intro
R Programming IntroR Programming Intro
R Programming Intro
 
Matlab1
Matlab1Matlab1
Matlab1
 
Chart and graphs in R programming language
Chart and graphs in R programming language Chart and graphs in R programming language
Chart and graphs in R programming language
 
Big Data Mining in Indian Economic Survey 2017
Big Data Mining in Indian Economic Survey 2017Big Data Mining in Indian Economic Survey 2017
Big Data Mining in Indian Economic Survey 2017
 
A brief introduction to apply functions
A brief introduction to apply functionsA brief introduction to apply functions
A brief introduction to apply functions
 
R programming intro with examples
R programming intro with examplesR programming intro with examples
R programming intro with examples
 
Introduction to matlab lecture 4 of 4
Introduction to matlab lecture 4 of 4Introduction to matlab lecture 4 of 4
Introduction to matlab lecture 4 of 4
 
R for Statistical Computing
R for Statistical ComputingR for Statistical Computing
R for Statistical Computing
 
Loops and functions in r
Loops and functions in rLoops and functions in r
Loops and functions in r
 
Programming in R
Programming in RProgramming in R
Programming in R
 
R basics
R basicsR basics
R basics
 
Basic Analysis using Python
Basic Analysis using PythonBasic Analysis using Python
Basic Analysis using Python
 
An Intoduction to R
An Intoduction to RAn Intoduction to R
An Intoduction to R
 

Dernier

Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Safe Software
 
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
?#DUbAI#??##{{(☎️+971_581248768%)**%*]'#abortion pills for sale in dubai@
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Safe Software
 

Dernier (20)

Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
 
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
 
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ..."I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century education
 
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodPolkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
 
MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
 
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
 
Ransomware_Q4_2023. The report. [EN].pdf
Ransomware_Q4_2023. The report. [EN].pdfRansomware_Q4_2023. The report. [EN].pdf
Ransomware_Q4_2023. The report. [EN].pdf
 
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
CNIC Information System with Pakdata Cf In Pakistan
CNIC Information System with Pakdata Cf In PakistanCNIC Information System with Pakdata Cf In Pakistan
CNIC Information System with Pakdata Cf In Pakistan
 
DBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor PresentationDBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor Presentation
 
Cyberprint. Dark Pink Apt Group [EN].pdf
Cyberprint. Dark Pink Apt Group [EN].pdfCyberprint. Dark Pink Apt Group [EN].pdf
Cyberprint. Dark Pink Apt Group [EN].pdf
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
 
FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024
 
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, AdobeApidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
 
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
 
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
 

statistical computation using R- an intro..

  • 2.  Introduction  R as a statistical software  Statistical features  R preliminaries  Functions in R  Graphics in R  Distributions  Conclusion  References
  • 3. Introduction  programming language and software environment for statistical computing and graphics.  S,S PLUS.  Developed by Ross Ihaka and Robert Gentleman at the University of Auckland, New Zealand.  Open source software  R works fundamentally by the question-and-answer model  Can be downloaded from http://R-Project.org
  • 4. R - as a Statistical software  It has very good computing performance  R makes its view especially in colleges & universities  It has excellent built in help system  Its graphical environment is flexible and powerful  Easy for new user  Easy to extend with user written functions  It provides scripting and interacting facilities  Vectors as the basic data structure
  • 5. Statistical features  R is an interpreted language  users typically access it through a command-line interpreter  Like other similar languages such as APL and MATLAB, R supports matrix arithmetic  R's data structures include vectors, matrices, arrays, data frames (similar to tables in a relational database) and lists.  R supports procedural programming with functions and, for some functions, object-oriented programming with generic functions.
  • 6. R-Preliminaries Common operators:  Arithmatic Operator + Addition - Subtract * Multiplication / Division ^ Exponential  Relational Operator < Lessthan > Greaterthan <= Lessthan Equal >= Greaterthan Equal == Is Equal to != Not Equal
  • 7.  Logical Operator ! NOT & AND | OR  Assignment Operator <- Left assignment -> Right assignment Eg : x<-2 Assigns the value 2 to the object x x^2->y Assigns the value x^2 to the object y Commands will be lines, starting with a # mark. To display the value of y, we type ‘print(y)’ or ‘y’
  • 8. Functions  function name is followed by a set of parentheses containing one or more arguments. Eg: plot(height,weight)  the function name is ‘plot’ and the arguments are ‘height’ and weight.  positional matching
  • 9. Method of data input  C function (concatenate) Eg: > x <- c(1, 2, 3) > y <- c(10, 20) > c(x, y, 5) # R command [1] 1 2 3 10 20 5  Sequence function seq (“sequence”), is used for equidistant series of numbers. Eg: > seq(4,9) # R command [1] 4 5 6 7 8 9
  • 10.  If you want a sequence in jumps of 2 Eg: > seq(4,10,2) [1] 4 6 8 10 Sequence operator “:” > 4:9 # R command [1] 4 5 6 7 8 9  Scan function Used to provide small quantities of data. variable=scan() # R command Used for creating data object Eg: wt=Scan(103,102,108); [1] 103 102 108
  • 11.  Rep function rep (“replicate”), is used to generate repeated values y=rep(x,n) # R command X<-c(rep(1,4),rep(2,2));  Data frames o provides the table of data in R object=data.frame(list of variables); # R command o Display the content of data frame with row no. o Column headings can be modified after creation of frame. o Colnames(name of data frame)= c(list of column under double quotes)
  • 12. Eg: n<-c(2, 3, 5) s<-c("aa", "bb", "cc") b<-c(TRUE, FALSE,TRUE) df<-data.frame(n, s, b) df o/p n s b 2 aa TRUE 3 bb FALSE 5 cc TRUE
  • 13.  Matrix function > x <- 1:12 > dim(x) <- c(3,4) > x [,1] [,2] [,3] [,4] [1,] 1 4 7 10 [2,] 2 5 8 11 [3,] 3 6 9 12 o The dim assignment function sets or changes the dimension attribute of x, causing R to treat the vector of 12 numbers as a 3 × 4 matrix o storage is column-major; that is, the elements of the first column are followed by those of the second, etc. o Convenient function to provide matrix type data. o Another function used to create a data frame. Object=matrix(c(data values) nrow=m,byrow=T/F) o The byrow=T switch causes the matrix to be filled in a row wise fashion rather than column wise
  • 14.  List function It is sometimes useful to combine a collection of objects into a larger composite object.This can be done using lists. Eg: > list1 <- c(5640,6180,6390,6805,7515) list2 <- c(3910,3885,5160,5645,7335) > mylist <- list(before=list1,after=list2) >mylist $before [1] 5640 6180 6390 6515 6805 7515 $after [1] 3910 3885 5160 5645 7335
  • 15.  Class function used to decide the class of the data object Eg: > a1<-c(‘x’,’y’); class(a1); o/p: character  Built in functions length() no. of elements of data max()the maximum element of data min() the minimum element of data sort() sorting in increasing magnitude -sort() “ decreasing “ etc
  • 16. Graphics in R  2 types of graphics function o High level function, which creates a new graph o Low level function, which adds elements to an already existing graph High level ploting functions plot() Scatter plot hist() Histogram boxplot() box & whisker barplot() bar diagram
  • 17. Arguments to plot function Argument explanation Main= Tittle Xlab= Label of X axis Ylab Label of Y axis Xlim= Specific X limit Ylim= “ Y limit Type= type of ‘p’ for points Pch= Style of points(bw 0&20) Col= colour
  • 18. Low level ploting functions Lines() Draw lines abline() Lines given by intercept and slopes points() Points text() Texts in the plot legent() List of symbols
  • 19.  > age<-c(5,10,15,20)  > freq<-c(10,15,30,20) >plot(age,freq,xlab=age,ylab=freq,pch=1,col="b lue",main="age vs frequency")
  • 20. Probability Distributions Distribution Rname Additional Argument Binomial binom size,probability Poisson pois lamda Geometric geom probability Hyper geom hyper m,n,k Normal norm mean,sd Uniform unif min,max Gamma gamma shape,scale Chi-square chisq df,df2,nCp F p df1,df2,nCp
  • 21.  Binomial Distribution > n<-10 > p<-.5 > pr<dbinom(x,n,p)# for pmf (pbinom for pdf) Error: object 'pr' not found > pr<-dbinom(x,n,p) > pr [1] 0.009765625 0.117187500 0.246093750 0.009765625 > pmf<-data.frame(x,pr) > pmf x pr 1 1 0.009765625 2 3 0.117187500 3 5 0.246093750 4 9 0.009765625 > plot(x,pr,type="h",main="binomial",lwd=2,xlab="x",ylab="pr")
  • 22. Conclusion  R is a flexible programming language designed to facilitate exploratory data analysis, classical statistical tests, and high- level graphics.  R is a full-fledged programming language, with a rich complement of mathematical functions, matrix operations and control structures.  With its rich and ever-expanding library of packages, R is on the leading edge of development in statistics, data analytics, and data mining.  R has proven itself a useful tool within the growing field of big data and has been integrated into several commercial packages, such as IBM SPSS and InfoSphere, as well as Mathematica.
  • 23. References  Introductory Statistics with R- Peter Dalgaard(2nd edition)  Statistical Computing with R- Eric Slud  Quick-R : Creating Graphs http://www.statmethods.net/graphs/