--3-Functions

#1-Introduction to Functions

​Intro to functions video​

#2-Function documentation

#Consult the documentation on the mean() function: 
#?mean or help(mean).
#Inspect the arguments of the mean() function using
#the args() function.
#Consult the documentation on the mean() function

?mean
help(mean)

# Inspect the arguments of the mean() function
args(mean)

#3-Use a function

#Calculate the average number of views for both linkedin 
#and facebook and assign the result to avg_li and avg_fb, 
#respectively. 
#Experiment with different types of argument matching!
#Print out both avg_li and avg_fb.

# The linkedin and facebook vectors have already 
#been created for you

linkedin <- c(16, 9, 13, 5, 2, 17, 14)

facebook <- c(17, 7, 5, 16, 8, 13, 14)

# Calculate average number of views

avg_li<-mean(linkedin)

avg_fb<-mean(facebook)

# Inspect avg_li and avg_fb

print(avg_li)

print(avg_fb)

#4-Use a function (2)

#5-Use a function (3)

#6-Functions inside functions

#7-Required, or optional?

#8-Writing Functions

​Writing function video​

#9-Write your own function

#10-Write your own function (2)

#11-Write your own function (3)

#12-Function scoping

#13-R passes arguments by value

#14-R you functional?

#15-R you functional? (2)

#16-R Packages

​R packages video​

#17-Load an R Package

#18-Different ways to load a package

Last updated