Apply named arguments and default values

A service business uses the following R function to calculate a charge in dollars. The hourly rate is in dollars per hour, and the booking fee is in dollars. No taxes or other charges apply.


R
service_charge <- function(hours, rate = 24, booking_fee = 9) {
  hours * rate + booking_fee
}


Calculate the dollar amount returned by each call below. Enter both amounts to two decimal places.


R
service_charge(booking_fee = 7, hours = 3)
service_charge(rate = 29, hours = 3)
Your answers

Create a free account to get started

Unlock full course notes by signing up

  • Video lessons taught by top educators
  • Practice questions with guided solutions
  • Written review notes for reference
  • Expert answers anytime from course tutors

More R Programming Basics Questions: