r4ds/workflow-style.Rmd

29 lines
469 B
Plaintext

# Workflow: code style {#workflow-style}
- Indenting and line breaks
```{r, eval = FALSE}
df %>% mutate(y = x + 1)
# vs
df %>%
mutate(
y = x + 1
)
```
- `mutate(df, y = x + 1)` vs `df %>% mutate(df, y = x + 1)`
- with ggplot2
```{r, eval = FALSE}
df %>%
ggplot(aes())
```
Don't forget to switch to plus!
- How long should your pipes be?
Too long vs too short
- Restyling with style.