speed = distance / time, and typos (#1402)

This commit is contained in:
Mitsuo Shiota 2023-04-08 23:34:21 +09:00 committed by GitHub
parent 4be5b37d87
commit 9483bef03f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 4 additions and 4 deletions

View File

@ -105,7 +105,7 @@ This makes it easier to skim the code.
flights |>
mutate(
speed = air_time / distance,
speed = distance / air_time,
dep_hour = dep_time %/% 100,
dep_minute = dep_time %% 100
)
@ -151,7 +151,7 @@ flights |>
```
After the first step of the pipeline, indent each line by two spaces.
RStudio will automatically put the spaces in for you after a line break following a `\>` .
RStudio will automatically put the spaces in for you after a line break following a `|>` .
If you're putting each argument on its own line, indent by an extra two spaces.
Make sure `)` is on its own line, and un-indented to match the horizontal position of the function name.
@ -233,7 +233,7 @@ flights |>
group_by(dest) |>
summarize(
distance = mean(distance),
speed = mean(air_time / distance, na.rm = TRUE)
speed = mean(distance / air_time, na.rm = TRUE)
) |>
ggplot(aes(x = distance, y = speed)) +
geom_smooth(
@ -292,7 +292,7 @@ knitr::include_graphics("screenshots/rstudio-nav.png")
## Summary
In this chapter, you've learn the most important principles of code style.
In this chapter, you've learned the most important principles of code style.
These may feel like a set of arbitrary rules to start with (because they are!) but over time, as you write more code, and share code with more people, you'll see how important a consistent style is.
And don't forget about the styler package: it's a great way to quickly improve the quality of poorly styled code.