0% found this document useful (0 votes)
69 views34 pages

Data Analytics Using R Intro To R

R is a statistical programming language commonly used for statistical analysis, data visualization, and other forms of data manipulation. Variables in R programming reserve memory locations to store values. Data in R can be structured as vectors, lists, matrices, arrays, data frames, or factors. Packages expand R's functionality and are installed and loaded separately. Help documents provide information on R functions and packages.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
69 views34 pages

Data Analytics Using R Intro To R

R is a statistical programming language commonly used for statistical analysis, data visualization, and other forms of data manipulation. Variables in R programming reserve memory locations to store values. Data in R can be structured as vectors, lists, matrices, arrays, data frames, or factors. Packages expand R's functionality and are installed and loaded separately. Help documents provide information on R functions and packages.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 34

Data us i n g

Analytic
s
Introduction to R
INTRODUCTION TO R
R is a statistical programming language commonly used for statistical analysis, data
visualization, and other forms of data manipulation.

R Packages R Core R Studio

DICT Cordilleras
R STUDIO
IDE

Environmen
t
Source

Files/Plots/
Control
DICT Cordilleras
Packages
R STUDIO
IDE
How to setup working directory
We can setup the directory in RStudio IDE by using or typing the:

getwd() – to check the current directory


setwd() – to change the current directory

DICT Cordilleras
Arithmetic

DICT Cordilleras
Relational Operators

DICT Cordilleras
Logical Operators

DICT Cordilleras
SPACES BETWEEN CHARACTERS
Spaces between characters do not affect the code. It’s a good practice to add a space between characters to make it easier
to read.

DICT Cordilleras
Order of Operations

DICT Cordilleras
Order of Operations

DICT Cordilleras
Using MultipleParenthesis

DICT Cordilleras
Variables
In programming languages, we need to use various variables to store various information.
Variables are the reserved memory location to store values. As we create a variable in our
program, some space is reserved in memory.

DICT Cordilleras
Variables
In programming languages, we need to use various variables to store various information.
Variables are the reserved memory location to store values. As we create a variable in our
program, some space is reserved in memory.

DICT Cordilleras
Variables Naming Conventions
In programming languages, we need to use various variables to store various information.
Variables are the reserved memory location to store values. As we create a variable in our
program, some space is reserved in memory.

x 2Dave (can't start with a number) total_score%


Total (can't have characters other than dot (.) or
.mean.avgs.set underscore (_)
total_minus_input .3total_score (can start with (.), but not followed
userAverageScores by a number
Dave17 _total_score (can't start with _ )

DICT Cordilleras
PROBLEM SOLVING
PROCESS
Tools
OBJECTIVE
Prepare breakfast for the family

PROCEDURE
prepare the pan
add a little oil to the pan get 1 egg
Containers and
break and put the egg in the pan
Ingredients
put salt
cook for 1 minute
remove the egg from the pan repeat process 5 more times

DICT Cordilleras serve the breakfast


R STUDIO
IDE
How to setup working directory
We can setup the directory in RStudio IDE by using or typing the:

getwd() – to check the current directory


setwd() – to change the current directory

DICT Cordilleras
Data Types and Data Structures

Data Data
Types Structures
DICT Cordilleras
Data Types

DICT Cordilleras
DATA 1 Vectors

STRUCTURES 2 Lists

3 Matrices

4 Arrays

5 Data Frames

6 Factors

DICT Cordilleras
Data Structures

DICT Cordilleras
Vector
In R, a sequence of elements which share the same data type is known as vector

Creating Vectors

1. Using the colon(:) operator

2. Using the seq() function

DICT Cordilleras
Vector
In R, a sequence of elements which share the same data type is known as vector

Creating Vectors

1. Using the c() function - combine

DICT Cordilleras
Vector
In R, a sequence of elements which share the same data type is known as vector

Creating Vectors

1. Using the c() function - combine

NOTE:c is variable
c() is the combine function

DICT Cordilleras
Vector
In R, a sequence of elements which share the same data type is known as vector

Accessing vector elements

Index number 5 not existing


DICT Cordilleras
Vector
In R, a sequence of elements which share the same data type is known as vector

DICT Cordilleras
Vector
In R, a sequence of elements which share the same data type is known as vector

DICT Cordilleras
Data Frame
Comprised of rows and columns, where elements of each column is of the same type

DICT Cordilleras
Data Frame
Comprised of rows and columns, where elements of each column is of the same type

Creating Data Frames Vectors as Columns

DICT Cordilleras
Data Frame
Comprised of rows and columns, where elements of each column is of the same type

Creating Data Frames

Import a CSV file into R

DICT Cordilleras
Data Frame
Comprised of rows and columns, where elements of each column is of the same type

Accessing Elements of a Data Frame

Returns items column as


Vector

Access elements as vector


DICT Cordilleras
Data Frame
Comprised of rows and columns, where elements of each column is of the same type

Slicing the Data Frame

DICT Cordilleras
Installing and Loading Packages
R packages are collections of functions and tools developed by the R community. They increase the power of R by improving
existing base R functionalities, or by adding new ones.

Example:

install.packages(“tidyverse”): Lets you install new packages (e.g., tidyverse package)

library(tidyverse): Lets you load and use packages (e.g., tidyverse package)

DICT Cordilleras
Accessing Help in R

DICT Cordilleras
Next : Data Exploration

You might also like