What’s R?
History
Ross Ihaka and Robert Gentleman. R: A language for data analysis and graphics. Journal of Computational and Graphical Statistics, 5(3):299–314, 1996
The philosophy of S (thus R)
“[W]e wanted users to be able to begin in an interactive environment, where they did not consciously think of themselves as programming. Then as their needs became clearer and their sophistication increased, they should be able to slide gradually into programming, when the language and system aspects would become more important.” - John Chambers
they needed to build language that would be suitable for interactive data analysis (more command-line based) as well as for writing longer programs (more traditional programming language-like).
Usage
R is heavily used by
Current stats
https://www.tiobe.com/tiobe-index/
INTRODUCTION TO R
FOR DATA SCIENCE AND BIOINFORMATICS
Siras Hakobyan, Davit Hakobyan
ABI
davit.hakobyan@abi.am, siras.hakobyan@abi.am
PLAN OF THE DAY
OMICSS-26
Time | Activity |
18:00–18:10 | Installation troubleshooting |
18:10–18:20 | Why R? History, ecosystem, where it is used |
18:20–18:45 | R syntax lecture |
18:45–19:00 | Quick syntax warm-up test (W3Schools) |
19:00–19:10 | Break |
19:10–20:00 | The R mindset: Vectorization and Data Manipulation Workshop |
WHAT CAN BE FOUND ON GITHUB?
OMICSS-26
Outline
OMICSS-26
Why Learn R?
OMICSS-26
R Syntax Basics
How to assign variables
There are three ways to assign a variable in R:
The most widely used is leftward assignment
OMICSS-26
Comments with #
R Syntax Basics
OMICSS-26
Case sensitivity
R Syntax Basics
OMICSS-26
Variable Types And Data Structures In R
OMICSS-26
Vectors in R: Basics and Operations
What is a Vector in R?
Arithmetic Operations on Vectors
R performs element-wise operations when vectors are of the same length:
If lengths differ, R recycles the shorter one:
OMICSS-26
String Vectors and Concatenation
Vectors can store strings
We use paste() or paste0() to concatenate elements:
grepl(pattern, vector) checks for a pattern match, returns a logical vector
sub() – replaces the first match in each string
gsub() – replaces all matches
OMICSS-26
Basic Functions
dim()
OMICSS-26
Help & Source Code Access
View(mean)
OMICSS-26
If/else
Control Structures
for loop
while loop
break
next
OMICSS-26
Functions in R
Step 1: Define a function
Step 2: Call the function
Why use functions?
mini-machines for repeated tasks
May have multiple arguments
May not return a value
May have a default value for an argument
OMICSS-26
Packages and libraries
How to install and load packages
Popular packages and their functionalities
OMICSS-26
INSTALLING BIOINFORMATICS PACKAGES
R has a powerful ecosystem for bioinformatics, mostly through the Bioconductor project and GitHub-hosted tools.
Bioconductor packages are curated and widely used in genomics, transcriptomics, and more.
Useful when packages aren't on CRAN or Bioconductor yet (e.g., new analysis methods).
OMICSS-26
That’s it!
Thank you for your attention
OMICSS-26