R for Beginners with applications 1 R for Beginners with applications 1
1. R for Beginners
with applications
Lesson 1:
Overview
first installation of R
basic operations from command line
R Studio - Visual Studio Code
First program
Packages
Write code from scratch and use
basic packages in a clear &
concise way, to do math and
statistics analysis.
From beginners to intermediate.
Abdesselam Filali 2025-05-17 18h00 Algiers time
3. 1
2
3
4
5
6
7
8
9
10
11
12
13
14
Overview
Overview of Rlang
R is a programming language for statistical computing and data visualization. It has been
adopted in the fields of data mining, bioinformatics and data analysis.
Presented by Abdesselam Filali - 2025-05-17
Giorgi, Federico M.; Ceraolo, Carmine; Mercatelli, Daniele (27 April 2022). "The R Language
: An Engine for Bioinformatics and Data Science". Life. 12 (5): 648.
The core R language is augmented by a large number of extension packages, containing
reusable code, documentation, and sample data.
R software is open-source and free software. R is a GNU Project and licensed under the GNU
General Public License.[3][10] It's written primarily in C, Fortran, and R itself. Precompiled
executables are provided for various operating systems.
As an interpreted language, R has a native command line interface. Moreover, multiple third-
party graphical user interfaces are available, such as Rstudio and Visual Studio Code —an
integrated development environment—, Jupyter—a notebook interface.
4. 1
2
3
4
5
6
7
8
9
10
11
12
13
14
History
Overview of Rlang
R was started by professors Ross Ihaka and Robert Gentleman as a programming language
to teach introductory statistics at the University of Auckland. The language was inspired by
the S programming language, with most S programs able to run unaltered in R. The
language was also inspired by Scheme's lexical scoping (lisp).
Presented by Abdesselam Filali - 2025-05-17
Ross Ihaka
co-originator of R
Robert Gentleman
https://en.wikipedia.org/wiki/R_(programming_language)
5. 1
2
3
4
5
6
7
8
9
10
11
12
13
14
packages
Overview of Rlang
R packages are extensions to the R statistical programming language. R packages contain
code, data, and documentation in a standardised collection format that can be installed by
users of R, typically via a centralised software repository such as CRAN (the Comprehensive
R Archive Network). The large number of packages available for R, and the ease of
installing and using them, has been cited as a major factor driving the widespread
adoption of the language in data science.
Presented by Abdesselam Filali - 2025-05-17
https://en.wikipedia.org/wiki/R_package
Base packages are immediately available when starting R and provide the necessary syntax
and commands for programming, computing, graphics production, basic arithmetic, and
statistical functionality.[
The Comprehensive R Archive Network (CRAN) was founded in 1997 by Kurt Hornik and
Friedrich Leisch to host R's source code, executable files, documentation, and user-created
packages.[21] Its name and scope mimic the Comprehensive TeX Archive Network
6. 1
2
3
4
5
6
7
8
9
10
11
12
13
14
Why use R ?
Overview of Rlang
• It is a great resource for data analysis, data visualization, data science and machine
learning
Presented by Abdesselam Filali - 2025-05-17
• It provides many statistical techniques (such as statistical tests, classification, clustering
and data reduction)
• It is easy to draw graphs in R, like pie charts, histograms, box plot, scatter plot, etc++
• It works on different platforms (Windows, Mac, Linux)
• It is open-source and free
• It has a large community support
• It has many packages (libraries of functions) that can be used to solve different
problems.
18. 1
2
3
4
5
6
7
8
9
10
11
12
13
14
Installing R
First installation of R
Windows + X or left clic on the start button
System Advanced system settings
https://www.computerhope.com/issues/ch000549.htm
Presented by Abdesselam Filali - 2025-05-17
32. 1
2
3
4
5
6
7
8
9
10
11
12
13
14
Variable names
First program
Presented by Abdesselam Filali - 2025-05-17
A variable can have a short name (like x and y) or a more descriptive name (age, carname,
total_volume). Rules for R variables are:
• A variable name must start with a letter and can be a combination of letters, digits,
period(.)
and underscore(_). If it starts with period(.), it cannot be followed by a digit.
• A variable name cannot start with a number or underscore (_)
• Variable names are case-sensitive (age, Age and AGE are three different variables)
• Reserved words cannot be used as variables (TRUE, FALSE, NULL, if...)
34. 1
2
3
4
5
6
7
8
9
10
11
12
13
14
Variable names
First program
Presented by Abdesselam Filali - 2025-05-17
In R, variables do not need to be declared with any particular type, and can even change
type after they have been set:
R has a variety of data types and object classes. You will learn much more about these as
you continue to get to know R.
35. 1
2
3
4
5
6
7
8
9
10
11
12
13
14
Basic data Types
First program
Presented by Abdesselam Filali - 2025-05-17
Basic data types in R can be divided into the following types:
numeric - (10.5, 55, 787)
integer - (1L, 55L, 100L, where the letter "L" declares this as an integer)
complex - (9 + 3i, where "i" is the imaginary part)
character (a.k.a. string) - ("k", "R is exciting", "FALSE", "11.5")
logical (a.k.a. boolean) - (TRUE or FALSE)
We can use the class() function to check the data type of a variable:
36. 1
2
3
4
5
6
7
8
9
10
11
12
13
14
Basic data Types
First program
Presented by Abdesselam Filali - 2025-05-17
There are three number types in R:
- numeric
- integer
- complex
Variables of number types are created when you assign a value to them.
37. 1
2
3
4
5
6
7
8
9
10
11
12
13
14
Basic data Types
First program
Presented by Abdesselam Filali - 2025-05-17
numeric
A numeric data type is the most common type in R, and contains any number with or without a
decimal, like: 10.5, 55, 787:
38. 1
2
3
4
5
6
7
8
9
10
11
12
13
14
Basic data Types
First program
Presented by Abdesselam Filali - 2025-05-17
integer
Integers are numeric data without decimals. This is used when you are certain that you will
never create a variable that should contain decimals. To create an integer variable, you must
use the letter L after the integer value: