In this assignment, we will build custom functions in R. As an example, the following function called addPercent converts a value into a percentage with one decimal place.
addPercent <- function(x){
percent <- round(x*100, digits = 1)
result <- paste(percent, “%”, sep = “”) return(result) } Below are a few output results from this function. > addPercent(.1)
[1] “10%”
> addPercent(10)
[1] “1000%”
> addPercent(10.1)
[1] “1010%”
> addPercent(0.1443)
[1] “14.4%”
1. Write a custom R function that inputs a temperature in Fahrenheit Fo and converts to Celsius Co. The relationship is Co = 5(Fo – 32)/9.
2. Write a custom R function that computes the sum of squares of two numbers.
3. Write a custom R function that takes any univariate dataset and calculates the mean, minimum, maximum, and standard deviation.
4. In statistics, a dataset needs to be transformed in order to meet certain assumptions. Write a custom R function that takes any univariate dataset and creates a histogram of the raw dataset and a histogram of the log-transformed dataset.
5. Write a custom R function of your own. Describe what your function does and produce the output.
Using a Word document, include your all your functions along with least four different output results from each of the functions 1 through 5. You may either copy and paste the codes and output results on a Word document or take the screen shots. If you take the screen shots, make sure to show the current date.