Syllabus, Last Week, Book and This Week
R - Script, Notebook and Markdown
GitHub
R Language
PRACTICE, SUMMARY and QUIZ
Next Week
Extended Syllabus PDF
Week 4 - Presentation LINK
<-#
(Pg. 22-27)
Scroll down :)
Scientific Calculator
Class
Vectors
Matrices
Arrays
Scientific Calculator
Scientific Calculator
Problem: Compute double, triple or higher order integrals
install.packages("cubature")
library(cubature)
f <- function(x) 1
adaptIntegrate(f,lowerLimit = c(0,0,0),upperLimit = c(4,4,4))
$integral
[1] XX
What is Function ?
A function is a set of statements organized together to perform a specific task
ex: mean() (arithmetic mean)
x <- c(1,2,3)
mean(x)
(1+2+3) / 3
Create a Function
Problem: Take a sample belonged to population and sum
pop <- 1:6 # This is my population
samp <- sample(pop, size = 2) # This is my sample, I choose two var.
sum(samp)
pop
samp
I want to create a new function named roll()
roll <- function(pop) {
pop <- 1:6
samp <- sample(pop, size = 2)
sum(samp)
}
roll()
Problem: I want to define population myself, in every time. remove pre-defined population and changed the name pop to box ?
roll2 <- function(box) {
samp <- sample(box, size = 2)
sum(samp)
}
roll2(box)
box ?
box = 1:6
roll2(box)
roll2(box = 1:6)
roll2(1:6)
Create a Function
print()
R Language - Part-I
List - Data Frame - Attributes - ATMOS
Udemy – Introduction to R, Section 3 (Video 22-25)
LINK - datacamp
R Language - Part-II
List and Data Frame