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