NEON-biodiversity / Ostats

O-statistics (community pairwise niche overlap statistics)
https://neon-biodiversity.github.io/Ostats/
Other
7 stars 2 forks source link

Dots argument for Ostats #7

Closed yyue-r closed 4 years ago

yyue-r commented 4 years ago

Hi Quentin@qdread !For the dots argument that you added to Ostats to pass on to density(), setting bw and adjust works, but n does not work. It generates an error saying that the n argument "matches multiple formal arguments".

qdread commented 4 years ago

Hi @yyue-r I actually get a different error than you did. Can you please give me the code that you used to generate that error, so that I can make sure we are looking at the same thing?

qdread commented 4 years ago

Okay, I got the error as well. It looks like it's because the argument is called n but we have multiple arguments in our function that also begin with n, they are nperm and nullqs. The reason this is a problem is because R, trying to be helpful, actually lets you abbreviate argument names. For example, if you say rnorm(n=10, m = 1) that is the same as saying rnorm(n=10, mean=1). But in this case, it causes a problem because R does not know that we actually mean n, it tries to find an argument beginning with n but it finds two and gives an error.

I am glad you found this error. I will just get rid of the dots and replace it with a regular list argument. I will commit that change in just a minute.

yyue-r commented 4 years ago

Hi Quentin, thanks! I was going to say the error should be reproduced if you run the vignette script up to line 141.

qdread commented 4 years ago

OK I committed the change in commit 25b15c8 .

Now Ostats() has an argument called density_args so you would pass a list of arguments for density() to it.

For example:

Ostats(traits, plots, sp, density_args = list(bw = "SJ", n = 1000, adjust = 2))

I'm closing this because I think it's fixed now! It should be very straightforward to update the vignette with this new way of writing the call to Ostats().