From 9483bef03f86d648cbb6b0ac12af501b47290927 Mon Sep 17 00:00:00 2001 From: Mitsuo Shiota <48662507+mitsuoxv@users.noreply.github.com> Date: Sat, 8 Apr 2023 23:34:21 +0900 Subject: [PATCH] speed = distance / time, and typos (#1402) --- workflow-style.qmd | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/workflow-style.qmd b/workflow-style.qmd index d74ac30..ed06f69 100644 --- a/workflow-style.qmd +++ b/workflow-style.qmd @@ -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.