This is a follow up to exercise Use and Modify Functions.
To make it even easier to work with your dinosaur mass estimation functions, create a function that lets you specify a dinosaur group, and then have the function automatically choose the right parameters for mass estimation for that group.
get_mass_from_length_by_name()
that:
length
and the name
of the dinosaur group.if
/else if
/else
statements to check if the name is one of the following values and if so set a
and b
to the appropriate values (from Seebacher 2001).a = 10.95
and b = 2.64
.a = 0.73
and b = 3.63
.a = 214.44
and b = 1.46
.NA
.
- Once the function has chosen the correct a
and b
values, have it run get_mass_from_length()
with the appropriate values and return the estimated mass.(Challenge) Modify your function so that if the group given in name
does not have a
and b
values, print out a message saying that there is no information to get the mass of the given group. The message should contain the name of the group, for example “No known estimation for Ankylosauria”. Use the function paste()
to do this. Doing this successfully will modify your answer to 2d, which is fine
a
and b
for Stegosauria:
a = 8.5
and b = 2.8
.mass = a * length ^ b
calculation.