[1] 15.5
[1] 4.5
[1] 4
[1] "SPECIES"
[1] "species"
[1] 1.61
[1] 1.61
A built-in function is one that you don’t need to install and load a package to use. Some examples include:
abs()
returns the absolute value of a number (e.g., abs(-2
))round()
, rounds a number (the first argument) to a given number of decimal places (the second argument) (e.g., round(12.1123, 2)
)sqrt()
, takes the square root of a number (e.g., sqrt(4)
)tolower()
, makes a string all lower case (e.g., tolower("HELLO")
)toupper()
, makes a string all upper case (e.g., toupper("hello")
)Use these built-in functions to print the following items:
round()
will default to using 0
if the second argument is not provided. Look at help(round)
or ?round
to see how this is indicated."species"
in all capital letters."SPECIES"
in all lower case letters.Optional Challenge: Do the same thing as task 6 (immediately above), but instead of creating the intermediate variable, perform both the square root and the round on a single line by putting the sqrt()
call inside the round()
call.
[1] 15.5
[1] 4.5
[1] 4
[1] "SPECIES"
[1] "species"
[1] 1.61
[1] 1.61