From 02651ef846c5f28d1ee761954682772aaada4951 Mon Sep 17 00:00:00 2001 From: Mine Cetinkaya-Rundel Date: Thu, 13 Jul 2023 11:52:21 -0400 Subject: [PATCH] Remove status (#1527) * Remove status * Remove status, no other changes * Leave a note about how to use status() * Remove status + visual editor made some changes * Remove backticks added by visual editor * Remove whitespaces --- EDA.qmd | 3 +-- _common.R | 1 + arrow.qmd | 3 +-- base-R.qmd | 2 -- communicate.qmd | 2 +- communication.qmd | 3 +-- data-import.qmd | 2 -- data-tidy.qmd | 2 -- data-transform.qmd | 2 -- data-visualize.qmd | 2 -- databases.qmd | 4 ++-- datetimes.qmd | 3 +-- factors.qmd | 3 +-- functions.qmd | 3 +-- import.qmd | 2 +- intro.qmd | 2 +- iteration.qmd | 2 -- joins.qmd | 3 +-- layers.qmd | 20 ++++++++++---------- logicals.qmd | 2 -- missing-values.qmd | 3 +-- numbers.qmd | 2 -- quarto-formats.qmd | 2 -- quarto.qmd | 4 +--- rectangling.qmd | 3 +-- regexps.qmd | 3 +-- spreadsheets.qmd | 2 -- strings.qmd | 2 -- visualize.qmd | 3 +-- webscraping.qmd | 3 +-- workflow-basics.qmd | 8 ++++---- workflow-help.qmd | 14 +++++++------- workflow-scripts.qmd | 43 +++++++++++++++++++++++-------------------- workflow-style.qmd | 2 -- 34 files changed, 63 insertions(+), 97 deletions(-) diff --git a/EDA.qmd b/EDA.qmd index 78630f9..720d271 100644 --- a/EDA.qmd +++ b/EDA.qmd @@ -1,10 +1,9 @@ # Exploratory data analysis {#sec-exploratory-data-analysis} ```{r} -#| results: "asis" #| echo: false + source("_common.R") -status("complete") ``` ## Introduction diff --git a/_common.R b/_common.R index e935cfe..036b733 100644 --- a/_common.R +++ b/_common.R @@ -25,6 +25,7 @@ options( ggplot2::theme_set(ggplot2::theme_gray(12)) +# use results: "asis" when setting a status for a chapter status <- function(type) { status <- switch(type, polishing = "should be readable but is currently undergoing final polishing", diff --git a/arrow.qmd b/arrow.qmd index 33db21c..30666cf 100644 --- a/arrow.qmd +++ b/arrow.qmd @@ -5,10 +5,9 @@ freeze: true # Arrow {#sec-arrow} ```{r} -#| results: "asis" #| echo: false + source("_common.R") -status("complete") ``` ## Introduction diff --git a/base-R.qmd b/base-R.qmd index abe4a38..4824cfd 100644 --- a/base-R.qmd +++ b/base-R.qmd @@ -1,11 +1,9 @@ # A field guide to base R {#sec-base-r} ```{r} -#| results: "asis" #| echo: false source("_common.R") -status("complete") ``` ## Introduction diff --git a/communicate.qmd b/communicate.qmd index 4bf803d..073efc6 100644 --- a/communicate.qmd +++ b/communicate.qmd @@ -1,8 +1,8 @@ # Communicate {#sec-communicate-intro .unnumbered} ```{r} -#| results: "asis" #| echo: false + source("_common.R") ``` diff --git a/communication.qmd b/communication.qmd index 9e90f77..af2ad1a 100644 --- a/communication.qmd +++ b/communication.qmd @@ -1,10 +1,9 @@ # Communication {#sec-communication} ```{r} -#| results: "asis" #| echo: false + source("_common.R") -status("complete") ``` ## Introduction diff --git a/data-import.qmd b/data-import.qmd index d80e542..8040cd4 100644 --- a/data-import.qmd +++ b/data-import.qmd @@ -1,11 +1,9 @@ # Data import {#sec-data-import} ```{r} -#| results: "asis" #| echo: false source("_common.R") -status("complete") ``` ## Introduction diff --git a/data-tidy.qmd b/data-tidy.qmd index 3770bc8..bd0b59b 100644 --- a/data-tidy.qmd +++ b/data-tidy.qmd @@ -1,11 +1,9 @@ # Data tidying {#sec-data-tidy} ```{r} -#| results: "asis" #| echo: false source("_common.R") -status("complete") ``` ## Introduction diff --git a/data-transform.qmd b/data-transform.qmd index dd8da70..c81932d 100644 --- a/data-transform.qmd +++ b/data-transform.qmd @@ -1,11 +1,9 @@ # Data transformation {#sec-data-transform} ```{r} -#| results: "asis" #| echo: false source("_common.R") -status("complete") ``` ## Introduction diff --git a/data-visualize.qmd b/data-visualize.qmd index f977616..0e449b2 100644 --- a/data-visualize.qmd +++ b/data-visualize.qmd @@ -1,11 +1,9 @@ # Data visualization {#sec-data-visualization} ```{r} -#| results: "asis" #| echo: false source("_common.R") -status("complete") ``` ## Introduction diff --git a/databases.qmd b/databases.qmd index ea95835..b67287b 100644 --- a/databases.qmd +++ b/databases.qmd @@ -1,10 +1,9 @@ # Databases {#sec-import-databases} ```{r} -#| results: "asis" #| echo: false + source("_common.R") -status("complete") ``` ## Introduction @@ -29,6 +28,7 @@ DBI is a low-level interface that connects to databases and executes SQL; dbplyr ```{r} #| label: setup #| message: false + library(DBI) library(dbplyr) library(tidyverse) diff --git a/datetimes.qmd b/datetimes.qmd index 2cb9c9e..533014d 100644 --- a/datetimes.qmd +++ b/datetimes.qmd @@ -1,10 +1,9 @@ # Dates and times {#sec-dates-and-times} ```{r} -#| results: "asis" #| echo: false + source("_common.R") -status("complete") # https://github.com/tidyverse/lubridate/issues/1058 options(warnPartialMatchArgs = FALSE) diff --git a/factors.qmd b/factors.qmd index 4242066..498b3fe 100644 --- a/factors.qmd +++ b/factors.qmd @@ -1,10 +1,9 @@ # Factors {#sec-factors} ```{r} -#| results: "asis" #| echo: false + source("_common.R") -status("complete") ``` ## Introduction diff --git a/functions.qmd b/functions.qmd index d46a8cc..2a8ac91 100644 --- a/functions.qmd +++ b/functions.qmd @@ -1,10 +1,9 @@ # Functions {#sec-functions} ```{r} -#| results: "asis" #| echo: false + source("_common.R") -status("complete") ``` ## Introduction diff --git a/import.qmd b/import.qmd index 75c3b54..f487e9b 100644 --- a/import.qmd +++ b/import.qmd @@ -1,8 +1,8 @@ # Import {#sec-import .unnumbered} ```{r} -#| results: "asis" #| echo: false + source("_common.R") ``` diff --git a/intro.qmd b/intro.qmd index abb5104..149f36d 100644 --- a/intro.qmd +++ b/intro.qmd @@ -1,8 +1,8 @@ # Introduction {#sec-intro} ```{r} -#| results: "asis" #| echo: false + source("_common.R") ``` diff --git a/iteration.qmd b/iteration.qmd index 0e1283a..63e3282 100644 --- a/iteration.qmd +++ b/iteration.qmd @@ -1,11 +1,9 @@ # Iteration {#sec-iteration} ```{r} -#| results: "asis" #| echo: false source("_common.R") -status("complete") ``` ## Introduction diff --git a/joins.qmd b/joins.qmd index bd8ce5a..5c8dba1 100644 --- a/joins.qmd +++ b/joins.qmd @@ -1,10 +1,9 @@ # Joins {#sec-joins} ```{r} -#| results: "asis" #| echo: false + source("_common.R") -status("complete") ``` ## Introduction diff --git a/layers.qmd b/layers.qmd index 7b68428..8a959e0 100644 --- a/layers.qmd +++ b/layers.qmd @@ -1,11 +1,9 @@ # Layers {#sec-layers} ```{r} -#| results: "asis" #| echo: false source("_common.R") -status("complete") ``` ## Introduction @@ -1005,14 +1003,16 @@ There are two other coordinate systems that are occasionally helpful. We can expand on the graphing template you learned in @sec-ggplot2-calls by adding position adjustments, stats, coordinate systems, and faceting: - ggplot(data = ) + - ( - mapping = aes(), - stat = , - position = - ) + - + - +``` +ggplot(data = ) + + ( + mapping = aes(), + stat = , + position = + ) + + + + +``` Our new template takes seven parameters, the bracketed words that appear in the template. In practice, you rarely need to supply all seven parameters to make a graph because ggplot2 will provide useful defaults for everything except the data, the mappings, and the geom function. diff --git a/logicals.qmd b/logicals.qmd index 171af32..017233a 100644 --- a/logicals.qmd +++ b/logicals.qmd @@ -1,11 +1,9 @@ # Logical vectors {#sec-logicals} ```{r} -#| results: "asis" #| echo: false source("_common.R") -status("complete") ``` ## Introduction diff --git a/missing-values.qmd b/missing-values.qmd index 6740244..a79d046 100644 --- a/missing-values.qmd +++ b/missing-values.qmd @@ -1,10 +1,9 @@ # Missing values {#sec-missing-values} ```{r} -#| results: "asis" #| echo: false + source("_common.R") -status("complete") ``` ## Introduction diff --git a/numbers.qmd b/numbers.qmd index 453491d..8fce8f4 100644 --- a/numbers.qmd +++ b/numbers.qmd @@ -1,11 +1,9 @@ # Numbers {#sec-numbers} ```{r} -#| results: "asis" #| echo: false source("_common.R") -status("complete") ``` ## Introduction diff --git a/quarto-formats.qmd b/quarto-formats.qmd index 0ae22ee..8c749b6 100644 --- a/quarto-formats.qmd +++ b/quarto-formats.qmd @@ -1,11 +1,9 @@ # Quarto formats {#sec-quarto-formats} ```{r} -#| results: "asis" #| echo: false source("_common.R") -status("complete") ``` ## Introduction diff --git a/quarto.qmd b/quarto.qmd index a84ff48..812a6e0 100644 --- a/quarto.qmd +++ b/quarto.qmd @@ -1,11 +1,9 @@ # Quarto {#sec-quarto} ```{r} -#| results: "asis" #| echo: false source("_common.R") -status("complete") ``` ## Introduction @@ -118,7 +116,7 @@ This will display the report in the viewer pane as shown in @fig-diamond-sizes-r knitr::include_graphics("quarto/diamond-sizes-report.png") ``` -When you render the document, Quarto sends the `.qmd` file to **knitr**, [https://yihui.org/knitr/](https://yihui.org/knitr/){.uri}, which executes all of the code chunks and creates a new markdown (`.md`) document which includes the code and its output. +When you render the document, Quarto sends the `.qmd` file to **knitr**, , which executes all of the code chunks and creates a new markdown (`.md`) document which includes the code and its output. The markdown file generated by knitr is then processed by **pandoc**, [https://pandoc.org](https://pandoc.org/){.uri}, which is responsible for creating the finished file. This process is shown in @fig-quarto-flow. The advantage of this two step workflow is that you can create a very wide range of output formats, as you'll learn about in @sec-quarto-formats. diff --git a/rectangling.qmd b/rectangling.qmd index d64a1f3..81c8a36 100644 --- a/rectangling.qmd +++ b/rectangling.qmd @@ -1,10 +1,9 @@ # Hierarchical data {#sec-rectangling} ```{r} -#| results: "asis" #| echo: false + source("_common.R") -status("complete") ``` ## Introduction diff --git a/regexps.qmd b/regexps.qmd index ce30f85..f95acdc 100644 --- a/regexps.qmd +++ b/regexps.qmd @@ -1,10 +1,9 @@ # Regular expressions {#sec-regular-expressions} ```{r} -#| results: "asis" #| echo: false + source("_common.R") -status("complete") ``` ## Introduction diff --git a/spreadsheets.qmd b/spreadsheets.qmd index 2f5dd27..26ddad0 100644 --- a/spreadsheets.qmd +++ b/spreadsheets.qmd @@ -1,11 +1,9 @@ # Spreadsheets {#sec-import-spreadsheets} ```{r} -#| results: "asis" #| echo: false source("_common.R") -status("complete") ``` ## Introduction diff --git a/strings.qmd b/strings.qmd index f2b9e5b..9bafb4c 100644 --- a/strings.qmd +++ b/strings.qmd @@ -1,11 +1,9 @@ # Strings {#sec-strings} ```{r} -#| results: "asis" #| echo: false source("_common.R") -status("complete") ``` ## Introduction diff --git a/visualize.qmd b/visualize.qmd index a7db459..b162ec4 100644 --- a/visualize.qmd +++ b/visualize.qmd @@ -1,10 +1,9 @@ # Visualize {#sec-visualize .unnumbered} ```{r} -#| results: "asis" #| echo: false + source("_common.R") -status("complete") ``` After reading the first part of the book, you understand (at least superficially) the most important tools for doing data science. diff --git a/webscraping.qmd b/webscraping.qmd index da8b8db..55054b6 100644 --- a/webscraping.qmd +++ b/webscraping.qmd @@ -1,10 +1,9 @@ # Web scraping {#sec-scraping} ```{r} -#| results: "asis" #| echo: false + source("_common.R") -status("complete") ``` ## Introduction diff --git a/workflow-basics.qmd b/workflow-basics.qmd index 53189e7..6e6cafa 100644 --- a/workflow-basics.qmd +++ b/workflow-basics.qmd @@ -1,11 +1,9 @@ # Workflow: basics {#sec-workflow-basics} ```{r} -#| results: "asis" #| echo: false source("_common.R") -status("complete") ``` You now have some experience running R code. @@ -196,8 +194,10 @@ Quotation marks and parentheses must always come in a pair. RStudio does its best to help you, but it's still possible to mess up and end up with a mismatch. If this happens, R will show you the continuation character "+": - > x <- "hello - + +``` +> x <- "hello ++ +``` The `+` tells you that R is waiting for more input; it doesn't think you're done yet. Usually, this means you've forgotten either a `"` or a `)`. Either add the missing pair, or press ESCAPE to abort the expression and try again. diff --git a/workflow-help.qmd b/workflow-help.qmd index a214b94..9dadda8 100644 --- a/workflow-help.qmd +++ b/workflow-help.qmd @@ -1,11 +1,9 @@ # Workflow: getting help {#sec-workflow-getting-help} ```{r} -#| results: "asis" #| echo: false source("_common.R") -status("complete") ``` This book is not an island; there is no single resource that will allow you to master R. @@ -68,11 +66,13 @@ reprex::reprex() A nicely rendered HTML preview will display in RStudio's Viewer (if you're in RStudio) or your default browser otherwise. The reprex is automatically copied to your clipboard (on RStudio Server or Cloud, you will need to copy this yourself): - ``` r - y <- 1:4 - mean(y) - #> [1] 2.5 - ``` +```` +``` r +y <- 1:4 +mean(y) +#> [1] 2.5 +``` +```` This text is formatted in a special way, called Markdown, which can be pasted to sites like StackOverflow or Github and they will automatically render it to look like code. Here's what that Markdown would look like rendered on GitHub: diff --git a/workflow-scripts.qmd b/workflow-scripts.qmd index e5244a8..5027b58 100644 --- a/workflow-scripts.qmd +++ b/workflow-scripts.qmd @@ -1,10 +1,9 @@ # Workflow: scripts and projects {#sec-workflow-scripts-projects} ```{r} -#| results: "asis" #| echo: false + source("_common.R") -status("complete") ``` This chapter will introduce you to two essential tools for organizing your code: scripts and projects. @@ -124,15 +123,17 @@ Three important principles for file naming are as follows: For example, suppose you have the following files in a project folder. - alternative model.R - code for exploratory analysis.r - finalreport.qmd - FinalReport.qmd - fig 1.png - Figure_02.png - model_first_try.R - run-first.r - temp.txt +``` +alternative model.R +code for exploratory analysis.r +finalreport.qmd +FinalReport.qmd +fig 1.png +Figure_02.png +model_first_try.R +run-first.r +temp.txt +``` There are a variety of problems here: it's hard to find which file to run first, file names contain spaces, there are two files with the same name but different capitalization (`finalreport` vs. `FinalReport`[^workflow-scripts-1]), and some names don't describe their contents (`run-first` and `temp`). @@ -140,15 +141,17 @@ There are a variety of problems here: it's hard to find which file to run first, Here's a better way of naming and organizing the same set of files: - 01-load-data.R - 02-exploratory-analysis.R - 03-model-approach-1.R - 04-model-approach-2.R - fig-01.png - fig-02.png - report-2022-03-20.qmd - report-2022-04-02.qmd - report-draft-notes.txt +``` +01-load-data.R +02-exploratory-analysis.R +03-model-approach-1.R +04-model-approach-2.R +fig-01.png +fig-02.png +report-2022-03-20.qmd +report-2022-04-02.qmd +report-draft-notes.txt +``` Numbering the key scripts make it obvious in which order to run them and a consistent naming scheme makes it easier to see what varies. Additionally, the figures are labelled similarly, the reports are distinguished by dates included in the file names, and `temp` is renamed to `report-draft-notes` to better describe its contents. diff --git a/workflow-style.qmd b/workflow-style.qmd index 36a10f9..9873206 100644 --- a/workflow-style.qmd +++ b/workflow-style.qmd @@ -1,11 +1,9 @@ # Workflow: code style {#sec-workflow-style} ```{r} -#| results: "asis" #| echo: false source("_common.R") -status("complete") ``` Good coding style is like correct punctuation: you can manage without it, butitsuremakesthingseasiertoread.