Correct function definition syntax
Exercise Type: Correction
Instructions
Correct the following, syntactically wrong function definitions:
A.
# function to calculate the area area of a circle
CircleArea <- function{r} (r^2 * 3.14)
B.
# function to calculate area of a rectangle
RectArea <- function(a,b} a * b}
C.
CelsiusToFahrenheit <- function(celsius{
# is the input numeric?
if(is.numeric(celsius)){
result <- celsius * 1.8 + 32
# if it is not the result should be missing
}else
message("Non-numeric input, returning NA!")
result <- NA
}
return(result)
}