Open annakrystalli opened 8 years ago
Hi Anna,
Here are a few comments, mostly of a cosmetic nature, after a first pass through your code.
Variable/function names: you've got a mix of styles and it would be nice to make those consistent. There are arguments for and against different options; this provides a good overview: http://stackoverflow.com/questions/1944910/what-is-your-preferred-style-for-naming-variables-in-r
For improved readability, I'd advocate for spacing and line breaks in if/else blocks as follows:
if (condition) {
...
} else {
...
}
or if it's a one-liner, spaces around the curly braces:
if (is.null(meta[[meta.var]])) { return(NA) }
Also, as per Hadley's style guide,
A closing curly brace should always go on its own line, unless it’s followed by else.
(The same goes for other blocks such as function bodies.)
I notice you've got several statements of the form:
if(any(!species %in% taxo.dat$species)){
which presumably works due to precedence rules in R, but I find it difficult not to associate the !
with the variable name itself and I think it's easier to understand with explicit brackets around the negated statement, even if it makes things a bit bracket-cluttered:
if (any(!(species %in% taxo.dat$species))) {
(Feel free to ignore me if I've misunderstood how the statement works!)
One last thing, I would suggest avoiding spaces in the names of the directories and files that you create for reasons of portability.
HTH, Tamora
Hey Tamora!
Thanks for having a proper look!
Your comments are all completely valid and will definitely need addressing.
I'd say consistency of variable/function/argument names and styles is the most pressing.
Some nice reformatting would be great. I'll leave that for a bit in case someone would like something straightforward.
The species names in fact I was thinking of doing away all together and use something like the NBN taxon version key. Same with observations in the master sheet.
Thanks again for taking the time to have a look and if you ever feel like suggesting any direct fixes feel free to make a pull request
I am sure my base code could be improved so I welcome suggestions and fixes to:
As this is the first time I am having my code reviewed, I would also appreciate feedback even on small but basic mistakes. I am hoping the project will offer an opportunity to learn best practices from others