SlideShare a Scribd company logo
R
Programming
İsmail SEYRİK
ismailseyrik@gmail.com
What does and does not
⪫  data handling and storage:
numeric, textual
⪫  matrix algebra
⪫  hash tables and regular
expressions
⪫  high-level data analytic
and statistical functions
⪫  programming language:
loops, branching,
subroutines
⪫  is not a database, but
connects to DBMSs
⪫  has no graphical user
interfaces, but connects to
Java, TclTk
⪫  language interpreter can
be very slow, but allows
to call own C/C++ code
⪫  no professional /
commercial support
R Commercial packages
Ø Many different datasets (and other
“objects”) available at same time
Ø Datasets can be of any dimension
Ø Functions can be modified
Ø Experience is interactive-you program
until you get exactly what you want
Ø One stop shopping - almost every
analytical tool you can think of is
available
Ø R is free and will continue to exist.
Nothing can make it go away, its price
will never increase.
Ø One datasets available at a given time
Ø Datasets are rectangular
Ø Functions are proprietary
Ø Experience is passive-you choose an
analysis and they give you everything they
think you need
Ø Tend to be have limited scope, forcing
you to learn additional programs; extra
options cost more and/or require you to
learn a different language (e.g., SPSS
Macros)
Ø They cost money. There is no guarantee
they will continue to exist, but if they do,
you can bet that their prices will always
increase
•  scc:~% R
•  R version 2.15.3 (2013-03-01)
•  Copyright (C) 2013 The R Foundation for
Statistical Computing
•  ISBN 3-900051-07-0
•  Platform: x86_64-unknown-linux-gnu (64-bit)
•  >
•  > 7 + 5 # arithmetic operations
•  [1] 12
•  > 6 – 3 * ( 8/2 – 1 )
•  [1] -3
•  > log(10) # commonly used functions
•  [1] 2.302585
•  > exp(7)
•  [1] 1096.633
•  > sqrt(2)
•  [1] 1.414214
sqrt(x), sum(x), sign(x), abs(x), …
# trigonometric
sin(x), cos(x), tan(x), asin(x), acos(x), …
# hyperbolic
sinh(x), cosh(x), …
# logarithmic and exponent
log(x), log10(x), log2(x) or log(x, base=10), exp(x)
# factorial and combination functions
factorial(n) , choose(n ,m)
# built-in constants
T, F, pi, LETTERS, letters, month.abb, month.name
•  > mat <- matrix(seq(1:21) ,nrow=7, byrow=TRUE)
•  > mat
•  [,1] [,2] [,3]
•  [1,] 1 2 3
•  [2,] 4 5 6
•  [3,] 7 8 9
•  [4,] 10 11 12
•  [5,] 13 14 15
•  [6,] 16 17 18
•  [7,] 19 20 21
R programmingmilano
R Objects
x1 x2 x3 x4 x5 x6
1
2
3
4
5
6
7
8
Z <-
A character string can contain arbitrary text. Sometimes it is useful to use a limited
vocabulary, with a small number of allowed words. A factor is a variable that can only
take such a limited number of values, which are called levels.
> a
[1] “A1" “1A" “U!"
[4] "M1" “A1" ”A3"
[7] “C1" “C11" “G1”
> class(a)
[1] "factor"
> as.character(a)
[1] “A1)" “1A" “U!"
[4] "M1" “A1" ”A3"
[7] “C1" “C11" “G1"
> as.integer(a)
[1] 1 2 2 2 2 4 2 3 2
> as.integer(as.character(a))
[1] NA NA NA NA NA NA NA NA NA NA NA NA
Warning message: NAs introduced by coercion
R programmingmilano
Graphics
•  Plot an object, like: plot(num.vec)
–  here plots against index numbers
•  Plot sends to graphic devices
–  can specify which graphic device you want
•  postscript, gif, jpeg, etc…
•  you can turn them on and off, like: dev.off()
•  Two types of plotting
–  high level: graphs drawn with one call
–  Low Level: add additional information to existing graph
Programming in R
•  Functions & Operators typically work on entire vectors
•  Expressions surrounded by {}
•  Codes separated by newlines, “;” not necessary
•  You can write your own functions and use them
How to model
•  Specify your model like this:
–  y ~ xi+ci, where
–  y = outcome variable, xi = main explanatory variables, ci =
covariates, + = add terms
–  Operators have special meanings
•  + = add terms, : = interactions, / = nesting, so on…
•  Modeling -- object oriented
–  each modeling procedure produces objects
–  classes and functions for each object
Modeling Example: Regression
carReg <- lm(speed~dist, data=cars)
carReg = becomes an object
to get summary of this regression, we type
summary(carReg)
to get only coefficients, we type
coef(carReg), or carReg$coef
don’t want intercept? add 0, so
carReg <- lm(speed~0+dist, data=cars)
LEAST SQUARES ESTIMATION
βˆˆ Xy =
For more information, check
out
R home page
http://www.r-project.org
Cran home page
https://cran.r-project.org/
İsmail SEYRİK
2018
Milan
ismailseyrik@gmail.com
Thank You

More Related Content

PPTX
WF ED 540, Class Meeting 2 - Identifying & converting data types, 2016
PDF
Anders Nielsen template model-builder
PPTX
Templates in c++
PDF
Functional Programming and Haskell - TWBR Away Day 2011
PPTX
Fyp presentation final
PDF
Functional Programming
WF ED 540, Class Meeting 2 - Identifying & converting data types, 2016
Anders Nielsen template model-builder
Templates in c++
Functional Programming and Haskell - TWBR Away Day 2011
Fyp presentation final
Functional Programming

What's hot (20)

PPT
3.6 radix sort
PPTX
MATRIX HASHING WITH TWO LEVEL OF COLLISION RESOLUTION
PDF
15 functional programming
PDF
DASH: A C++ PGAS Library for Distributed Data Structures and Parallel Algorit...
PPT
Intro matlab
PDF
Graph Analyses with Python and NetworkX
PPT
PDF
Data science : R Basics Harvard University
PPTX
Radix Sort
PDF
R language, an introduction
PDF
Machine Learning Basics for Web Application Developers
PPTX
Advanced data structures slide 1 2
PDF
Fluent14
PPTX
An introduction to matlab
PDF
working with matrices in r
PDF
Line drawing algorithm
PDF
8. R Graphics with R
 
PPTX
Deep learning
PPTX
Csci101 lect01 first_program
PDF
Aaa ped-Data-8- manipulation: Plotting and Visualization
3.6 radix sort
MATRIX HASHING WITH TWO LEVEL OF COLLISION RESOLUTION
15 functional programming
DASH: A C++ PGAS Library for Distributed Data Structures and Parallel Algorit...
Intro matlab
Graph Analyses with Python and NetworkX
Data science : R Basics Harvard University
Radix Sort
R language, an introduction
Machine Learning Basics for Web Application Developers
Advanced data structures slide 1 2
Fluent14
An introduction to matlab
working with matrices in r
Line drawing algorithm
8. R Graphics with R
 
Deep learning
Csci101 lect01 first_program
Aaa ped-Data-8- manipulation: Plotting and Visualization
Ad

Similar to R programmingmilano (20)

PPT
MATLAB-tutorial for Image Processing with Lecture 3.ppt
PPTX
Matlab_Harshal.pptx
PPTX
Introduction to R.pptx
PPT
introduction to R with example, Data science
PPT
Slides on introduction to R by ArinBasu MD
PPT
Basics of R-Progranmming with instata.ppt
PPT
PPT
17641.ppt
PPT
How to obtain and install R.ppt
PDF
The Fuss about || Haskell | Scala | F# ||
PPT
Introduction to R for Data Science Technology
PPT
Advanced Data Analytics with R Programming.ppt
PPTX
Introduction To Programming In R for data analyst
PDF
R Programming - part 1.pdf
PPTX
MATLAB_PROGRAMMING_BASICTOADVANCEDSCRIPT
PDF
Migrating from matlab to python
PPTX
Programming in python
PDF
Lecture1_computer vision-2023.pdf
PDF
Standardizing on a single N-dimensional array API for Python
PDF
An R primer for SQL folks
MATLAB-tutorial for Image Processing with Lecture 3.ppt
Matlab_Harshal.pptx
Introduction to R.pptx
introduction to R with example, Data science
Slides on introduction to R by ArinBasu MD
Basics of R-Progranmming with instata.ppt
17641.ppt
How to obtain and install R.ppt
The Fuss about || Haskell | Scala | F# ||
Introduction to R for Data Science Technology
Advanced Data Analytics with R Programming.ppt
Introduction To Programming In R for data analyst
R Programming - part 1.pdf
MATLAB_PROGRAMMING_BASICTOADVANCEDSCRIPT
Migrating from matlab to python
Programming in python
Lecture1_computer vision-2023.pdf
Standardizing on a single N-dimensional array API for Python
An R primer for SQL folks
Ad

Recently uploaded (20)

PDF
Raksha Bandhan Grocery Pricing Trends in India 2025.pdf
PDF
Addressing The Cult of Project Management Tools-Why Disconnected Work is Hold...
PPTX
Agentic AI Use Case- Contract Lifecycle Management (CLM).pptx
PPTX
history of c programming in notes for students .pptx
PDF
Which alternative to Crystal Reports is best for small or large businesses.pdf
PPTX
ai tools demonstartion for schools and inter college
PDF
T3DD25 TYPO3 Content Blocks - Deep Dive by André Kraus
PDF
EN-Survey-Report-SAP-LeanIX-EA-Insights-2025.pdf
PPTX
Introduction to Artificial Intelligence
PDF
How to Migrate SBCGlobal Email to Yahoo Easily
PPTX
Operating system designcfffgfgggggggvggggggggg
PDF
Upgrade and Innovation Strategies for SAP ERP Customers
PPTX
Lecture 3: Operating Systems Introduction to Computer Hardware Systems
PPTX
VVF-Customer-Presentation2025-Ver1.9.pptx
PPTX
Transform Your Business with a Software ERP System
PDF
Adobe Illustrator 28.6 Crack My Vision of Vector Design
PDF
Claude Code: Everyone is a 10x Developer - A Comprehensive AI-Powered CLI Tool
PDF
medical staffing services at VALiNTRY
PDF
PTS Company Brochure 2025 (1).pdf.......
PDF
Digital Strategies for Manufacturing Companies
Raksha Bandhan Grocery Pricing Trends in India 2025.pdf
Addressing The Cult of Project Management Tools-Why Disconnected Work is Hold...
Agentic AI Use Case- Contract Lifecycle Management (CLM).pptx
history of c programming in notes for students .pptx
Which alternative to Crystal Reports is best for small or large businesses.pdf
ai tools demonstartion for schools and inter college
T3DD25 TYPO3 Content Blocks - Deep Dive by André Kraus
EN-Survey-Report-SAP-LeanIX-EA-Insights-2025.pdf
Introduction to Artificial Intelligence
How to Migrate SBCGlobal Email to Yahoo Easily
Operating system designcfffgfgggggggvggggggggg
Upgrade and Innovation Strategies for SAP ERP Customers
Lecture 3: Operating Systems Introduction to Computer Hardware Systems
VVF-Customer-Presentation2025-Ver1.9.pptx
Transform Your Business with a Software ERP System
Adobe Illustrator 28.6 Crack My Vision of Vector Design
Claude Code: Everyone is a 10x Developer - A Comprehensive AI-Powered CLI Tool
medical staffing services at VALiNTRY
PTS Company Brochure 2025 (1).pdf.......
Digital Strategies for Manufacturing Companies

R programmingmilano

  • 2. What does and does not ⪫  data handling and storage: numeric, textual ⪫  matrix algebra ⪫  hash tables and regular expressions ⪫  high-level data analytic and statistical functions ⪫  programming language: loops, branching, subroutines ⪫  is not a database, but connects to DBMSs ⪫  has no graphical user interfaces, but connects to Java, TclTk ⪫  language interpreter can be very slow, but allows to call own C/C++ code ⪫  no professional / commercial support
  • 3. R Commercial packages Ø Many different datasets (and other “objects”) available at same time Ø Datasets can be of any dimension Ø Functions can be modified Ø Experience is interactive-you program until you get exactly what you want Ø One stop shopping - almost every analytical tool you can think of is available Ø R is free and will continue to exist. Nothing can make it go away, its price will never increase. Ø One datasets available at a given time Ø Datasets are rectangular Ø Functions are proprietary Ø Experience is passive-you choose an analysis and they give you everything they think you need Ø Tend to be have limited scope, forcing you to learn additional programs; extra options cost more and/or require you to learn a different language (e.g., SPSS Macros) Ø They cost money. There is no guarantee they will continue to exist, but if they do, you can bet that their prices will always increase
  • 4. •  scc:~% R •  R version 2.15.3 (2013-03-01) •  Copyright (C) 2013 The R Foundation for Statistical Computing •  ISBN 3-900051-07-0 •  Platform: x86_64-unknown-linux-gnu (64-bit) •  >
  • 5. •  > 7 + 5 # arithmetic operations •  [1] 12 •  > 6 – 3 * ( 8/2 – 1 ) •  [1] -3 •  > log(10) # commonly used functions •  [1] 2.302585 •  > exp(7) •  [1] 1096.633 •  > sqrt(2) •  [1] 1.414214
  • 6. sqrt(x), sum(x), sign(x), abs(x), … # trigonometric sin(x), cos(x), tan(x), asin(x), acos(x), … # hyperbolic sinh(x), cosh(x), … # logarithmic and exponent log(x), log10(x), log2(x) or log(x, base=10), exp(x) # factorial and combination functions factorial(n) , choose(n ,m) # built-in constants T, F, pi, LETTERS, letters, month.abb, month.name
  • 7. •  > mat <- matrix(seq(1:21) ,nrow=7, byrow=TRUE) •  > mat •  [,1] [,2] [,3] •  [1,] 1 2 3 •  [2,] 4 5 6 •  [3,] 7 8 9 •  [4,] 10 11 12 •  [5,] 13 14 15 •  [6,] 16 17 18 •  [7,] 19 20 21
  • 9. R Objects x1 x2 x3 x4 x5 x6 1 2 3 4 5 6 7 8 Z <-
  • 10. A character string can contain arbitrary text. Sometimes it is useful to use a limited vocabulary, with a small number of allowed words. A factor is a variable that can only take such a limited number of values, which are called levels. > a [1] “A1" “1A" “U!" [4] "M1" “A1" ”A3" [7] “C1" “C11" “G1” > class(a) [1] "factor" > as.character(a) [1] “A1)" “1A" “U!" [4] "M1" “A1" ”A3" [7] “C1" “C11" “G1" > as.integer(a) [1] 1 2 2 2 2 4 2 3 2 > as.integer(as.character(a)) [1] NA NA NA NA NA NA NA NA NA NA NA NA Warning message: NAs introduced by coercion
  • 12. Graphics •  Plot an object, like: plot(num.vec) –  here plots against index numbers •  Plot sends to graphic devices –  can specify which graphic device you want •  postscript, gif, jpeg, etc… •  you can turn them on and off, like: dev.off() •  Two types of plotting –  high level: graphs drawn with one call –  Low Level: add additional information to existing graph
  • 13. Programming in R •  Functions & Operators typically work on entire vectors •  Expressions surrounded by {} •  Codes separated by newlines, “;” not necessary •  You can write your own functions and use them
  • 14. How to model •  Specify your model like this: –  y ~ xi+ci, where –  y = outcome variable, xi = main explanatory variables, ci = covariates, + = add terms –  Operators have special meanings •  + = add terms, : = interactions, / = nesting, so on… •  Modeling -- object oriented –  each modeling procedure produces objects –  classes and functions for each object
  • 15. Modeling Example: Regression carReg <- lm(speed~dist, data=cars) carReg = becomes an object to get summary of this regression, we type summary(carReg) to get only coefficients, we type coef(carReg), or carReg$coef don’t want intercept? add 0, so carReg <- lm(speed~0+dist, data=cars)
  • 17. For more information, check out R home page http://www.r-project.org Cran home page https://cran.r-project.org/