#####
# Example Function
#####
# Attach packages
library(tidyverse)
# Write function
add_fifty <- function(x, a) {
if(x > 200) return("x needs to be less than 200.") # Pick a number to limit x
if(a < -50) return("a needs to be greater than -50") # Pick a number to limit y
y <- x + a + 50 # Do calculation
print(y)
if(y >= 100) {
print("Yay, that's a good number.") # Aiming for a value of y that is greater than 100 (picked a random number and chose that for some reason)
} else {
print("I dislike numbers less than 100.") # Made function not like numbers less than chosen number
}
}
# Write if statements before actual calculation
add_fifty(16, 2)
add_fifty(75, -51)
add_fifty(120, 20)
add_fifty(90, -10)
add_fifty(50, -49)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.