These questions are meant to test understanding of the lessons about writing R functions
Suppose we have a simple function to calculate a circle's diameter from its circumference:
circumference_to_diameter <- function(circumference){
diameter <- circumference / pi
return(diameter)
}
Then, we run the following bit of code:
diameter <- 30
circumference_to_diameter(15)
If we then ask R for the value of the object diameter
, what answer
will we get?
9.54
30
15
4.77
BNL <- function(week = 1, days = 5, living_room = 3, forgiven = -1){
lyrics <- data.frame(week, days, living_room, forgiven)
return(lyrics)
}
BNL()
## week days living_room forgiven
## 1 1 5 3 -1
Which of the following lines will return this dataframe:
week | days | living_room | forgiven |
---|---|---|---|
45 | 45 | 44 | 47 |
BNL(45, 45, 44, week = 47)
BNL(w = 45, l = 44, d = 45, f = 47)
BNL(data.frame(week = 45, days = 45, living_room = 44, forgiven = 47))
BNL(forgiven = 45, living_room = 45, days = 44, week = 47)