diff --git a/data-transform.qmd b/data-transform.qmd index 4851055..f6fb73b 100644 --- a/data-transform.qmd +++ b/data-transform.qmd @@ -726,7 +726,7 @@ Note the handy pattern for combining ggplot2 and dplyr. It's a bit annoying that you have to switch from `|>` to `+`, but it's not too much of a hassle once you get the hang of it. There's another common variation on this pattern that we can see in some data about baseball players. -The following code uses data from the **Lahman** package to compare what proportion of times a player hits the ball vs. the number of attempts they take: +The following code uses data from the **Lahman** package to compare what proportion of times a player gets a hit vs. the number of times they try to put the ball in play: ```{r} batters <- Lahman::Batting |> diff --git a/workflow-help.qmd b/workflow-help.qmd index f840a87..73874b5 100644 --- a/workflow-help.qmd +++ b/workflow-help.qmd @@ -16,6 +16,7 @@ This section describes a few tips on how to get help and to help you keep learni If you get stuck, start with Google. Typically adding "R" to a query is enough to restrict it to relevant results: if the search isn't useful, it often means that there aren't any R-specific results available. +Additionally, adding package names like "tidyverse" or "ggplot2" will help narrow down the results to code that will feel more familiar to you as well, e.g., "how to make a boxplot in R" vs. "how to make a boxplot in R with ggplot2". Google is particularly useful for error messages. If you get an error message and you have no idea what it means, try googling it! Chances are that someone else has been confused by it in the past, and there will be help somewhere on the web. @@ -112,6 +113,9 @@ There are three things you need to include to make your example reproducible: re Finish by checking that you have actually made a reproducible example by starting a fresh R session and copying and pasting your script. +Creating reprexes is not trivial, and it will take some practice to learn to create good, truly minimal reprexes. +However, learning to ask questions that include the code, and investing the time to make it reproducible will continue to pay off as you learn and master R. + ## Investing in yourself You should also spend some time preparing yourself to solve problems before they occur. diff --git a/workflow-style.qmd b/workflow-style.qmd index ecd8827..dfdec30 100644 --- a/workflow-style.qmd +++ b/workflow-style.qmd @@ -273,9 +273,12 @@ knitr::include_graphics("screenshots/rstudio-nav.png") ```{r} #| eval: false - flights|>filter(dest=="IAH")|>group_by(year,month,day)|>summarize(n=n(),delay=mean(arr_delay,na.rm=TRUE))|>filter(n>10) + flights|>filter(dest=="IAH")|>group_by(year,month,day)|>summarize(n=n(), + delay=mean(arr_delay,na.rm=TRUE))|>filter(n>10) - flights|>filter(carrier=="UA",dest%in%c("IAH","HOU"),sched_dep_time>0900,sched_arr_time<2000)|>group_by(flight)|>summarize(delay=mean(arr_delay,na.rm=TRUE),cancelled=sum(is.na(arr_delay)),n=n())|>filter(n>10) + flights|>filter(carrier=="UA",dest%in%c("IAH","HOU"),sched_dep_time> + 0900,sched_arr_time<2000)|>group_by(flight)|>summarize(delay=mean( + arr_delay,na.rm=TRUE),cancelled=sum(is.na(arr_delay)),n=n())|>filter(n>10) ``` ## Summary