Merge branch 'master' of github.com:hadley/r4ds
This commit is contained in:
commit
1e1ef1ee0e
|
@ -56,7 +56,7 @@ The main downside of this form is that it forces you to name each intermediate e
|
||||||
|
|
||||||
Whenever I write code like this, I invariably use the wrong number on one line and then spend 10 minutes scratching my head and trying to figure out what went wrong with my code.
|
Whenever I write code like this, I invariably use the wrong number on one line and then spend 10 minutes scratching my head and trying to figure out what went wrong with my code.
|
||||||
|
|
||||||
You may also worry that this form creates many copies of your data and takes up a lot of memory. Suprisingly, that's not the case. First, note that proactively worrying about memory is not a useful way to spend your time: worry about it when it becomes a problem (i.e. you run out of memory), not before. Second, R isn't stupid, and it will share columns across data frames, where possible. Let's take a look at an actual data manipulation pipeline where we add a new column to `ggplot2::diamonds`:
|
You may also worry that this form creates many copies of your data and takes up a lot of memory. Surprisingly, that's not the case. First, note that proactively worrying about memory is not a useful way to spend your time: worry about it when it becomes a problem (i.e. you run out of memory), not before. Second, R isn't stupid, and it will share columns across data frames, where possible. Let's take a look at an actual data manipulation pipeline where we add a new column to `ggplot2::diamonds`:
|
||||||
|
|
||||||
```{r}
|
```{r}
|
||||||
diamonds <- ggplot2::diamonds
|
diamonds <- ggplot2::diamonds
|
||||||
|
@ -208,7 +208,7 @@ The pipe is a powerful tool, but it's not the only tool at your disposal, and it
|
||||||
|
|
||||||
## Other tools from magrittr
|
## Other tools from magrittr
|
||||||
|
|
||||||
All packages in the tidyverse automatically make `%>%` alivaiable for you, so you don't normally load magrittr explicitly. However, there are some other useful tools inside magrittr that you might want to try out:
|
All packages in the tidyverse automatically make `%>%` available for you, so you don't normally load magrittr explicitly. However, there are some other useful tools inside magrittr that you might want to try out:
|
||||||
|
|
||||||
* When working with more complex pipes, it's sometimes useful to call a
|
* When working with more complex pipes, it's sometimes useful to call a
|
||||||
function for its side-effects. Maybe you want to print out the current
|
function for its side-effects. Maybe you want to print out the current
|
||||||
|
|
Loading…
Reference in New Issue