Learn the built-in mathematical functions in R. This tutorial is part of the Working With Data module of the R Programming course offered by r-squared.
3. r-squared
Slide 3
Working With Data
www.r-squared.in/rprogramming
â Data Types
â Data Structures
â Data Creation
â Data Info
â Data Subsetting
â Comparing R Objects
â Importing Data
â Exporting Data
â Data Transformation
â Numeric Functions
â String Functions
â Mathematical Functions
4. r-squared
In this unit, we will explore the following mathematical functions:
Slide 4
Mathematical Functions
www.r-squared.in/rprogramming
â Arithmetic Operators
â Column/ Row Operators
â Cumulative Operators
â Sampling
â Set Operations
â Logarithm
8. r-squared
Slide 8
Column & Row Operations
www.r-squared.in/rprogramming
Operator Description
colSums Sum of column values
rowSums Sum of row values
colMeans Mean of column values
rowMeans Mean of row values
9. r-squared
Slide 9
Column & Row Operations
www.r-squared.in/rprogramming
Examples
> # example 1
> m
[,1] [,2] [,3]
[1,] 1 4 7
[2,] 2 5 8
[3,] 3 6 9
> colSums(m) # sum of columns
[1] 6 15 24
> rowSums(m) # sum of rows
[1] 12 15 18
> colMeans(m) # mean of columns
[1] 2 5 8
> rowMeans(m) # mean of rows
[1] 4 5 6
23. r-squared
In the next module, we will explore selection statements in R:
Slide 23
Next Steps...
www.r-squared.in/rprogramming
â if()
â if else()
â ifelse()
â switch()
24. r-squared
Slide 24
Connect With Us
www.r-squared.in/rprogramming
Visit r-squared for tutorials
on:
â R Programming
â Business Analytics
â Data Visualization
â Web Applications
â Package Development
â Git & GitHub