pearselab / r-intro-jocelyn-cuthbert

r-intro-jocelyn-cuthbert created by GitHub Classroom
0 stars 0 forks source link

The bunnies aren't reproducing at a defined rate for #6 #4

Closed jocelyn-cuthbert closed 7 years ago

jocelyn-cuthbert commented 7 years ago

Hi Will, I am working on #6, but can't figure out how to add in defined values for a,b, and c and have that be included in the plot. The one sad dot does not show the bunny growth rate that I made all these somewhat scientifically correct assumptions about.

willpearse commented 7 years ago

You seem to have closed this issue - would you like some help anyway?

The wonderful thing about arguments in functions is that you don't have to add defined values for those parameters - your wrapper function can take whatever values the user gives you and then work with those. You can, of course, set default arguments (see below), but they can always over-ride them if they wish.

strange_func <- function(x, a=3, b=10, c=25){
    print(paste("The product of these numbers are:", x*a*c))
}
strange_func(10) #...uses defaults
strange_func(10, 4, 2, 10) #...doesn't use defaults

Does that make sense? Do bear in mind that I'm seven hours ahead of you, so if you've got any other questions you want answered today try to ask them now while I'm still awake :D

willpearse commented 7 years ago

Does that help @jocelyn-cuthbert ?