⌘+C
<- function(temp_f) {
fahrenheit_to_celsius return((temp_f - 32) * 5 / 9)
}fahrenheit_to_celsius(temp_f = 98.6)
Jihong Zhang*, Ph.D
Educational Statistics and Research Methods (ESRM) Program*
University of Arkansas
August 18, 2025
fahrenheit_to_celsius
that converts a temperature from Fahrenheit to Celsius.circle_area
that calculates the area of a circle given its radius.pi
in R and test the function with r = 5.standardized()
to avoid code repetition.greet
that takes two arguments, name
(default = “World”) and punctuation
(default = “!”). The function should return a greeting message.greet("Alice", "?")
should return "Hello, Alice?"
.sum()
function by passing named arguments (x = 3, y = 5
) and explain how the function handles them.result
accessible outside the function.multiply_all()
that accepts a variable number of arguments and multiplies all the numbers together. Test your function with multiply_all(2, 3, 4)
.mean()
function by using the help page. Explain why it can accept additional arguments like y
in the code below:Write a function rect_prism_volume()
that calculates the volume of a rectangular prism given its length, width, and height. Inside this function, create another function rect_area()
to calculate the base area.
The formula for the volume of a rectangular prism is:
V = A_b \times h
A_b = l \times w
where:
V = Volume of the rectangular prism,
A_b = base area
l = Length,
w = Width,
h = Height.
rescale()
that rescales a numeric vector to the range 0 to 1.rescale()
function to rescale the columns of the following data frame: