Week 1
Week 1
WEEK 1
INTRODUCTION TO R
This week marks the beginning of our exploration into the world of data
analysis with a detailed introduction to R, utilizing the powerful platform of
RStudio. The aim of this initial phase is to build a solid foundation in
understanding R's unique syntax, an essential skill set for future data
analysts. Students will be introduced to the basics of writing and running R
scripts, covering fundamental programming concepts such as variables,
data types, and elementary operations. This foundational week is crafted to
provide students with the tools they need to effectively work within the
RStudio environment, preparing for more complex subjects in subsequent
weeks.
Prepared by Dr. Mogana Darshini Ganggayah
[email protected]
Page 01
LEARNING OUTCOMES
1. Understand and describe the essential elements
of R's syntax, including data types and basic
operations, demonstrating a foundational grasp of
programming concepts in R.
2. Apply knowledge of R syntax to write and execute
simple scripts, effectively using various data types
and structures to solve basic programming tasks.
3. Analyse and troubleshoot R scripts,
demonstrating the ability to identify and rectify
errors, and optimize code efficiency in basic data
analysis scenarios.
03 04
Installing and importing Data structures in R
packages in R
OVERVIEW OF R PROGRAMMING
IN DATA ANALYSIS
R programming has emerged as a cornerstone in the realm of
data analysis, offering a comprehensive suite of tools for data
manipulation, statistical modeling, and graphical representation.
Its open-source nature and extensive community support have
fostered a rich ecosystem of packages tailored for diverse
analytical needs across various domains. R's syntax and
programming environment are specifically designed with data
analysis and statistics in mind, enabling analysts to conduct
complex data operations, create compelling visualizations, and
develop sophisticated statistical models with relative ease. By
leveraging R's capabilities, data analysts can uncover insights
from data, facilitate decision-making processes, and contribute
to evidence-based research, making it an indispensable tool in
today’s data-driven world.
Presentation By Benjamin
ETW2001 FOUNDATIONS OF DATA Shah
ANALYSIS
KEY ASPECTS OF R PROGRAMMING LANGUAGE
Page 05
BENEFITS OF DATA
ANALYSIS
1. Informed Decision Making
BENEFITS OF DATA
ANALYSIS
BENEFITS OF DATA
ANALYSIS
3. Enhancing Customer Experience
BENEFITS OF DATA
ANALYSIS
4. Optimizing Operations
BENEFITS OF DATA
ANALYSIS
5. Driving Innovation
BENEFITS OF DATA
ANALYSIS
6. Risk Management
BENEFITS OF DATA
ANALYSIS
7. Enhancing Performance
BENEFITS OF DATA
ANALYSIS
8. Personalization
OVERVIEW OF R STUDIO
STEP-BY-STEP GUIDE
Step 1: Installing R and RStudio
1. Install R:
Visit the Comprehensive R Archive Network (CRAN) at
https://cran.r-project.org/.
Select the download link for your operating system
(Windows, macOS, or Linux).
Follow the installation instructions for your OS.
2. Install RStudio:
Go to the RStudio download page at
https://www.rstudio.com/products/rstudio/download/.
Download the free version of RStudio Desktop that
matches your operating system.
Install RStudio by following the prompts.
R Script: area where you can write and Environment/History (top right): Displays
edit your R scripts variables in your current workspace and
command history.
1. Create a New Project: Go to File > New Project to create a new workspace. This helps in managing your
work for different projects separately.
2. Create an R Script: Click File > New File > R Script to open a new script tab in the top-left panel. This is where
you'll write longer blocks of code.
a) Single-Line Comments:
Single-line comments are created using the # symbol.
Everything following the # on that line is treated as a
comment.
Variable assignment in R is
the process of storing data in
a variable. In R, you can
assign values to variables
using different operators.
Here are the main ways to
perform variable assignment
Installing Packages
This command needs to be run only once per R
Before you can use a library in R, you need to install it.
installation, as it downloads and installs the package on
This is typically done using the install.packages()
your system.
function.
Loading libraries
Note:
You need an internet connection to install
packages from CRAN (the Comprehensive R This command needs to be run each time you start a
Archive Network). new R session and want to use the package
Some packages may depend on other packages,
which are usually installed automatically as needed.
Regularly updating R and its packages ensures
access to the latest functions and bug fixes.
B) Use Case:
2. VECTOR
A) Description:
B) Use Case:
3. LIST
A) Description:
B) Use Case:
4. MATRIX
A) Description:
B) Use Case:
Commonly used in
mathematical computations,
statistical analyses, and any
context where data is naturally
two-dimensional.
5. ARRAY
A) Description:
B) Use Case:
6. DATAFRAME
A) Description:
B) Use Case: