--1-A quick refresher

#1-Writing a function in R

​Writing function video​

#2-Writing a function

#Using the function template, write a function ratio() 
#that takes arguments x and y and returns their ratio, x / y.
#Check your function by calling it with the arguments 3 and 4.

# Define ratio() function
ratio <- function(x, y) {
  cevi= x/y
  return(cevi)
}
# Call ratio() with arguments 3 and 4
ratio(3,4)

#3-Arguments

#Here's a rather cryptic call to mean(). 
#Rewrite the call to follow the best practices we just discussed. 
#Use the natural ordering of the arguments, 
#which you can find by typing ?mean in the console.

# Rewrite the call to follow best practices
mean(c(1:9, NA), trim = 0.1, na.rm = TRUE)

#4-Function output

#5-Environments

​R Environment video​

#6-Testing your understanding of scoping (1)

#7-Testing your understanding of scoping (2)

#8-Testing your understanding of scoping (3)

#9-Data structures

​Data structures in R video​

#10-Atomic types of vectors

#11-Subsetting lists

#12-Exploring lists

#13-for loops

​For loops video​

#14-A safer way to create the sequence

#15-Keeping output

Last updated