Fix typos (#141)
* Fix typos I also changed the order of words in a sentence, but that might be a matter of style. * Changed determinant to determine Take care! * Determinant changed to determine For some reason, the Travis CI didn't build when I changed the last file. I'm trying again, hope it isn't a bother (is there a term for spamming a github repo?)
This commit is contained in:
parent
6d5cb638f2
commit
154cd9486b
|
@ -115,7 +115,7 @@ x <- c(1:10, Inf)
|
|||
rescale01(x)
|
||||
```
|
||||
|
||||
Because we've extract the code into a function, we only need to make the fix in one place:
|
||||
Because we've extracted the code into a function, we only need to make the fix in one place:
|
||||
|
||||
```{r}
|
||||
rescale01 <- function(x) {
|
||||
|
@ -125,7 +125,7 @@ rescale01 <- function(x) {
|
|||
rescale01(x)
|
||||
```
|
||||
|
||||
This is an important part of the "do no repeat yourself" (or DRY) principle. The more repitition you have in your code, the more places you need to remember to update when things change (and they always code!), and the more likely you are to create bugs over time.
|
||||
This is an important part of the "do not repeat yourself" (or DRY) principle. The more repetition you have in your code, the more places you need to remember to update when things change (and they always could!), and the more likely you are to create bugs over time.
|
||||
|
||||
### Practice
|
||||
|
||||
|
@ -175,7 +175,7 @@ It's important to remember that functions are not just for the computer, but are
|
|||
|
||||
The name of a function is important. Ideally the name of your function will be short, but clearly evoke what the function does. However, it's hard to come up with concise names, and autocomplete makes it easy to type long names, so it's better to err on the side of clear descriptions, rather than short names.
|
||||
|
||||
Generally, function names should be verbs, and arguments should be nouns. There are some exceptions: nouns are ok if the function computes a very well known noun (i.e. `mean()` is better than `compute_mean()`), or accessing some property of an object (i.e. `coef()` is better than `get_coefficients()`). A good sign that a noun might be a better choice is if you're using a very broad verb like "get", "compute", "calculate", or determine. Use your best judgement and don't be afraid to rename a function if you later figure out a better name.
|
||||
Generally, function names should be verbs, and arguments should be nouns. There are some exceptions: nouns are ok if the function computes a very well known noun (i.e. `mean()` is better than `compute_mean()`), or accessing some property of an object (i.e. `coef()` is better than `get_coefficients()`). A good sign that a noun might be a better choice is if you're using a very broad verb like "get", "compute", "calculate", or "determine". Use your best judgement and don't be afraid to rename a function if you figure out a better name later.
|
||||
|
||||
```{r, eval = FALSE}
|
||||
# Too short
|
||||
|
|
Loading…
Reference in New Issue