These exercises are about the functions sections of Introduction to R.
Exercise 1 - Functions
– Create a function which takes one number and returns the square of that number
## [1] 9
– Create a function which takes two numbers and returns the mean
## [1] 2
## The total length of my vectors is 8
## [1] 4.25
## [[1]]
## [1] 1 3
##
## [[2]]
## mean sum multiple
## 1 2 4 3
– Create a function which takes one argument and finds the smallest number whose factorial is greater than that argument.
## [1] 7
## [1] 70
– Add a if and else statement in your function to only calculate factorial code if argument is a numeric.
## [1] 7
## Please provide a numeric argument!
Exercise 2 - Scripts
Lets try to put as much together that we have learnt thus far. This will be a multistep challenge. Break it down and use pseudocode to help. Start by working the code interactively, then turn it into a script.
## [1] "Gene_h"