SlideShare a Scribd company logo
2
Most read
6
Most read
10
Most read
Introduction to R
What is R programming language?
• Open source software enviroment for statistical computing and
graphics.
• Object-oriented language i.e we create objects and manipulate them
as intended.
• Functional programming language (it provides many tools for the
creation and manipulation of functions) written primarily in C and
Fortran.
• It's flexible, extensible and comprehesive for productivity.
Why learn R?
Who uses R?
All fields
•
• ICRAFuseR slack channel
• RLadies groups
• Africa R group
• Nairobi R group
• Twitter
R user communities and groups
• A user interface
• An intergrated
development
enviroment (IDE)
What is Rstudio?
NHSLinf
1. Downloading and installing R and Rstudio
To Install R
1. Open an internet browser and go to www.r-project.org.
2. Click the "download R" link in the middle of the page under "Getting Started.”
3. Select a CRAN location (a mirror site) and click the corresponding link.
4. Click on the "Download R for (Mac) OS X" / "Download R for Windows”/ "Download R for Linux" link
under Download and Install R.
5. Click on the file containing the latest version of R .
6. Save the file, double-click it to open, and follow the installation instructions.
7. Now that R is installed, you need to download and install RStudio.
To Install Rstudio
1. Go to www.rstudio.com and click on the "Download RStudio" button
2. Click on "Download RStudio Desktop.”
3. Click on the version recommended for your system, save the file on your computer, double-click it to
open, and then drag and drop it to your applications folder.
Where do I start?
What are they?
A package bundles together code, data, documentation, and tests, and is easy to share with others.
Who develops them?
Any R developer who wants to contribute to the open source community.
How to install?
1. install.packages(”name of package”)
2. Use the Rstudio interface i.e Packages ->install -> type name of package on popup -> install
How to use them in R
1. Load the package i.e library(name of package)
2. You can now start using the package functions
How to get help
1. Use package cheat sheets available online
2. In R console type ??function
R packages
 Data frames
 Vectors
a <- c(1,2,5.3,6,-2,4) # numeric vector
b <- c("one","two","three") # character vector
c <- c(TRUE,TRUE,TRUE,FALSE,TRUE,FALSE) #logical vector
 Matrices
y<-matrix(1:20, nrow=5,ncol=4) # generates 5 x 4 numeric matrix
 Arrays. Are similar to matrices but can have more than two dimensions.
 Lists
w <- list(name="Fred", mynumbers=a, mymatrix=y, age=5.3)
 Factors
gender <- c(rep("male",20), rep("female", 30))
gender <- factor(gender)
Data types in R
2. R resources and materials
1. Package cheat sheets
2. Rstudio help page ??function
3. R for data science book
4. Landscape portal blogs http://landscapeportal.org/blog/categories/r/
5. Data camp
6. Coursera
7. Other R users
8. Just google it
• Always create new folders for each project if applicable
• Always create “New projects” for projects
File New project New Directory Empty Project specify new
directory name and browse to a location on your computer. Create new project
• Set working directory setwd /Users/FMusili/ OneDrive - CGIAR /Scripts/Climatemodule/Climate”)
• Use relative paths (data/shp/Africa-bnd-outline.shp) instead of absolute paths (“/Users/FMusili/
OneDrive - CGIAR /Scripts/Climatemodule/Climate/data/shp/Africa-bnd-outline.shp”)
• Use short and comprehesive object names. Use a naming convention consistently.
• Use comments when writing scripts for easy re-visit by you or someone else “#”
• Use code management systems like github, gitlab, bitbucket etc. for version control and code
backup
• Pipe your code as much as possible -----to be illustrated later
• Practise! Practise! Practise! Practise! Practise! Practise! Practise! Practise! Practise!
Some good practices when programming in R
# My first program in R Programming
myString <- "Hello, World!"
print ( myString)
[1] "Hello, World!"
Basic R
n <- 15
n
[1] 15
5 -> n
n
[1] 5
x <- 1
X <- 10
x
[1] 1
X
[1] 10
m<-3+sqrt(10)
m
[1] 6.162278
R is case sensitive
(10 + 2) * 5
[1] 60
2019
• Introduction to R on 24th October 2019 by Faith Musili
• Reading data in R on 21st November 2019 by Makui Parmutia
• Data manipulation in R (1) on 5th December 2019 by Aida Bargues-
Tobella
2020
….......
ICRAFuseR seminars for beginners

More Related Content

PPTX
R Programming Language
PPTX
Introduction to R
PPT
R programming slides
PPTX
R programming language
PPTX
Introduction to statistical software R
PPTX
Statistical Analysis with R -I
PPTX
R programming
PPTX
ML - Multiple Linear Regression
R Programming Language
Introduction to R
R programming slides
R programming language
Introduction to statistical software R
Statistical Analysis with R -I
R programming
ML - Multiple Linear Regression

What's hot (20)

PDF
Intro to RStudio
PDF
Introduction to R and R Studio
PDF
Introduction to Rstudio
PPTX
R programming presentation
PPT
Theory of computing
PPTX
Chart and graphs in R programming language
PPTX
R programming
PPTX
Introduction to R programming
PPTX
Probability distribution in R
PPT
Application of SPSS by umakant bhaskar gohatre
PPTX
Programming in R
PPTX
ProLog (Artificial Intelligence) Introduction
PPTX
Quantifiers and its Types
PDF
Data analytics using R programming
PPTX
2. R-basics, Vectors, Arrays, Matrices, Factors
PDF
Statistics For Data Science | Statistics Using R Programming Language | Hypot...
PPTX
R Programming
PPTX
Unit 1 - R Programming (Part 2).pptx
PPT
Sum of subsets problem by backtracking 
PPTX
Regression
Intro to RStudio
Introduction to R and R Studio
Introduction to Rstudio
R programming presentation
Theory of computing
Chart and graphs in R programming language
R programming
Introduction to R programming
Probability distribution in R
Application of SPSS by umakant bhaskar gohatre
Programming in R
ProLog (Artificial Intelligence) Introduction
Quantifiers and its Types
Data analytics using R programming
2. R-basics, Vectors, Arrays, Matrices, Factors
Statistics For Data Science | Statistics Using R Programming Language | Hypot...
R Programming
Unit 1 - R Programming (Part 2).pptx
Sum of subsets problem by backtracking 
Regression
Ad

Similar to Introduction to r (20)

PPTX
Getting Started with R
PPTX
R Brownbag Seminar 2.1
PPTX
BUSINESS ANALYTICS WITH R SOFTWARE DIAST
PDF
Introduction to R software, by Leire ibaibarriaga
PDF
R Intro
PDF
محاضرة برنامج التحليل الكمي R program د.هديل القفيدي
PPTX
Data Science With R Programming Unit - II Part-1.pptx
PPTX
Data science with R Unit - II Part-1.pptx
PPTX
Workshop presentation hands on r programming
PDF
R training
PDF
R Traning-Session-I 21-23 May 2025 Updated Alpha.pdf
PPTX
R for Beginners with applications 1 R for Beginners with applications 1
PPTX
R Programming and Lab - Unit I PPTX with examples
PDF
محاضرة برنامج التحليل الكمي R program د.هديل القفيدي
PDF
R-Language-Lab-Manual-lab-1.pdf
PDF
R-Language-Lab-Manual-lab-1.pdf
PDF
R-Language-Lab-Manual-lab-1.pdf
PDF
Unit1_Introduction to R.pdf
PDF
Data analysis in R
PPTX
Intro to data science module 1 r
Getting Started with R
R Brownbag Seminar 2.1
BUSINESS ANALYTICS WITH R SOFTWARE DIAST
Introduction to R software, by Leire ibaibarriaga
R Intro
محاضرة برنامج التحليل الكمي R program د.هديل القفيدي
Data Science With R Programming Unit - II Part-1.pptx
Data science with R Unit - II Part-1.pptx
Workshop presentation hands on r programming
R training
R Traning-Session-I 21-23 May 2025 Updated Alpha.pdf
R for Beginners with applications 1 R for Beginners with applications 1
R Programming and Lab - Unit I PPTX with examples
محاضرة برنامج التحليل الكمي R program د.هديل القفيدي
R-Language-Lab-Manual-lab-1.pdf
R-Language-Lab-Manual-lab-1.pdf
R-Language-Lab-Manual-lab-1.pdf
Unit1_Introduction to R.pdf
Data analysis in R
Intro to data science module 1 r
Ad

Recently uploaded (20)

PDF
CHAPTER 3 Cell Structures and Their Functions Lecture Outline.pdf
PPTX
Taita Taveta Laboratory Technician Workshop Presentation.pptx
PDF
Sciences of Europe No 170 (2025)
PPTX
Protein & Amino Acid Structures Levels of protein structure (primary, seconda...
PPTX
Science Quipper for lesson in grade 8 Matatag Curriculum
PPTX
famous lake in india and its disturibution and importance
PPTX
2Systematics of Living Organisms t-.pptx
PPTX
Overview of calcium in human muscles.pptx
DOCX
Q1_LE_Mathematics 8_Lesson 5_Week 5.docx
PPT
protein biochemistry.ppt for university classes
PPTX
C1 cut-Methane and it's Derivatives.pptx
PDF
Phytochemical Investigation of Miliusa longipes.pdf
PDF
Lymphatic System MCQs & Practice Quiz – Functions, Organs, Nodes, Ducts
PPTX
ECG_Course_Presentation د.محمد صقران ppt
PPTX
neck nodes and dissection types and lymph nodes levels
PPTX
Application of enzymes in medicine (2).pptx
PDF
lecture 2026 of Sjogren's syndrome l .pdf
PPTX
2. Earth - The Living Planet earth and life
PPTX
2. Earth - The Living Planet Module 2ELS
PDF
Placing the Near-Earth Object Impact Probability in Context
CHAPTER 3 Cell Structures and Their Functions Lecture Outline.pdf
Taita Taveta Laboratory Technician Workshop Presentation.pptx
Sciences of Europe No 170 (2025)
Protein & Amino Acid Structures Levels of protein structure (primary, seconda...
Science Quipper for lesson in grade 8 Matatag Curriculum
famous lake in india and its disturibution and importance
2Systematics of Living Organisms t-.pptx
Overview of calcium in human muscles.pptx
Q1_LE_Mathematics 8_Lesson 5_Week 5.docx
protein biochemistry.ppt for university classes
C1 cut-Methane and it's Derivatives.pptx
Phytochemical Investigation of Miliusa longipes.pdf
Lymphatic System MCQs & Practice Quiz – Functions, Organs, Nodes, Ducts
ECG_Course_Presentation د.محمد صقران ppt
neck nodes and dissection types and lymph nodes levels
Application of enzymes in medicine (2).pptx
lecture 2026 of Sjogren's syndrome l .pdf
2. Earth - The Living Planet earth and life
2. Earth - The Living Planet Module 2ELS
Placing the Near-Earth Object Impact Probability in Context

Introduction to r

  • 2. What is R programming language? • Open source software enviroment for statistical computing and graphics. • Object-oriented language i.e we create objects and manipulate them as intended. • Functional programming language (it provides many tools for the creation and manipulation of functions) written primarily in C and Fortran. • It's flexible, extensible and comprehesive for productivity.
  • 5. • • ICRAFuseR slack channel • RLadies groups • Africa R group • Nairobi R group • Twitter R user communities and groups
  • 6. • A user interface • An intergrated development enviroment (IDE) What is Rstudio? NHSLinf
  • 7. 1. Downloading and installing R and Rstudio To Install R 1. Open an internet browser and go to www.r-project.org. 2. Click the "download R" link in the middle of the page under "Getting Started.” 3. Select a CRAN location (a mirror site) and click the corresponding link. 4. Click on the "Download R for (Mac) OS X" / "Download R for Windows”/ "Download R for Linux" link under Download and Install R. 5. Click on the file containing the latest version of R . 6. Save the file, double-click it to open, and follow the installation instructions. 7. Now that R is installed, you need to download and install RStudio. To Install Rstudio 1. Go to www.rstudio.com and click on the "Download RStudio" button 2. Click on "Download RStudio Desktop.” 3. Click on the version recommended for your system, save the file on your computer, double-click it to open, and then drag and drop it to your applications folder. Where do I start?
  • 8. What are they? A package bundles together code, data, documentation, and tests, and is easy to share with others. Who develops them? Any R developer who wants to contribute to the open source community. How to install? 1. install.packages(”name of package”) 2. Use the Rstudio interface i.e Packages ->install -> type name of package on popup -> install How to use them in R 1. Load the package i.e library(name of package) 2. You can now start using the package functions How to get help 1. Use package cheat sheets available online 2. In R console type ??function R packages
  • 9.  Data frames  Vectors a <- c(1,2,5.3,6,-2,4) # numeric vector b <- c("one","two","three") # character vector c <- c(TRUE,TRUE,TRUE,FALSE,TRUE,FALSE) #logical vector  Matrices y<-matrix(1:20, nrow=5,ncol=4) # generates 5 x 4 numeric matrix  Arrays. Are similar to matrices but can have more than two dimensions.  Lists w <- list(name="Fred", mynumbers=a, mymatrix=y, age=5.3)  Factors gender <- c(rep("male",20), rep("female", 30)) gender <- factor(gender) Data types in R
  • 10. 2. R resources and materials 1. Package cheat sheets 2. Rstudio help page ??function 3. R for data science book 4. Landscape portal blogs http://landscapeportal.org/blog/categories/r/ 5. Data camp 6. Coursera 7. Other R users 8. Just google it
  • 11. • Always create new folders for each project if applicable • Always create “New projects” for projects File New project New Directory Empty Project specify new directory name and browse to a location on your computer. Create new project • Set working directory setwd /Users/FMusili/ OneDrive - CGIAR /Scripts/Climatemodule/Climate”) • Use relative paths (data/shp/Africa-bnd-outline.shp) instead of absolute paths (“/Users/FMusili/ OneDrive - CGIAR /Scripts/Climatemodule/Climate/data/shp/Africa-bnd-outline.shp”) • Use short and comprehesive object names. Use a naming convention consistently. • Use comments when writing scripts for easy re-visit by you or someone else “#” • Use code management systems like github, gitlab, bitbucket etc. for version control and code backup • Pipe your code as much as possible -----to be illustrated later • Practise! Practise! Practise! Practise! Practise! Practise! Practise! Practise! Practise! Some good practices when programming in R
  • 12. # My first program in R Programming myString <- "Hello, World!" print ( myString) [1] "Hello, World!" Basic R n <- 15 n [1] 15 5 -> n n [1] 5 x <- 1 X <- 10 x [1] 1 X [1] 10 m<-3+sqrt(10) m [1] 6.162278 R is case sensitive (10 + 2) * 5 [1] 60
  • 13. 2019 • Introduction to R on 24th October 2019 by Faith Musili • Reading data in R on 21st November 2019 by Makui Parmutia • Data manipulation in R (1) on 5th December 2019 by Aida Bargues- Tobella 2020 …....... ICRAFuseR seminars for beginners