Don't transform non-crossref links
This commit is contained in:
		@@ -103,7 +103,7 @@ Exercises</h2>
 | 
			
		||||
<section id="visual-editor" data-type="sect1">
 | 
			
		||||
<h1>
 | 
			
		||||
Visual editor</h1>
 | 
			
		||||
<p>The Visual editor in RStudio provides a <a href="#chp-https://en.wikipedia.org/wiki/WYSIWYM" data-type="xref">#chp-https://en.wikipedia.org/wiki/WYSIWYM</a> interface for authoring Quarto documents. Under the hood, prose in Quarto documents (<code>.qmd</code> files) is written in Markdown, a lightweight set of conventions for formatting plain text files. In fact, Quarto uses Pandoc markdown (a slightly extended version of Markdown that Quarto understands), including tables, citations, cross-references, footnotes, divs/spans, definition lists, attributes, raw HTML/TeX, and more as well as support for executing code cells and viewing their output inline. While Markdown is designed to be easy to read and write, as you will see in <a href="#sec-source-editor" data-type="xref">#sec-source-editor</a>, it still requires learning new syntax. Therefore, if you’re new to computational documents like <code>.qmd</code> files but have experience using tools like Google Docs or MS Word, the easiest way to get started with Quarto in RStudio is the visual editor.</p>
 | 
			
		||||
<p>The Visual editor in RStudio provides a <a href="https://en.wikipedia.org/wiki/WYSIWYM">WYSIWYM</a> interface for authoring Quarto documents. Under the hood, prose in Quarto documents (<code>.qmd</code> files) is written in Markdown, a lightweight set of conventions for formatting plain text files. In fact, Quarto uses Pandoc markdown (a slightly extended version of Markdown that Quarto understands), including tables, citations, cross-references, footnotes, divs/spans, definition lists, attributes, raw HTML/TeX, and more as well as support for executing code cells and viewing their output inline. While Markdown is designed to be easy to read and write, as you will see in <a href="#sec-source-editor" data-type="xref">#sec-source-editor</a>, it still requires learning new syntax. Therefore, if you’re new to computational documents like <code>.qmd</code> files but have experience using tools like Google Docs or MS Word, the easiest way to get started with Quarto in RStudio is the visual editor.</p>
 | 
			
		||||
<p>In the visual editor you can either use the buttons on the menu bar to insert images, tables, cross-references, etc. or you can use the catch-all <kbd>⌘ /</kbd> shortcut to insert just about anything. If you are at the beginning of a line (as shown below), you can also enter just <kbd>/</kbd> to invoke the shortcut.</p>
 | 
			
		||||
<div class="cell">
 | 
			
		||||
<div class="cell-output-display">
 | 
			
		||||
@@ -339,7 +339,7 @@ Inline code</h2>
 | 
			
		||||
<blockquote class="blockquote">
 | 
			
		||||
<p>We have data about 53940 diamonds. Only 126 are larger than 2.5 carats. The distribution of the remainder is shown below:</p>
 | 
			
		||||
</blockquote>
 | 
			
		||||
<p>When inserting numbers into text, <code><a href="#chp-https://rdrr.io/r/base/format" data-type="xref">#chp-https://rdrr.io/r/base/format</a></code> is your friend. It allows you to set the number of <code>digits</code> so you don’t print to a ridiculous degree of accuracy, and a <code>big.mark</code> to make numbers easier to read. You might combine these into a helper function:</p>
 | 
			
		||||
<p>When inserting numbers into text, <code><a href="https://rdrr.io/r/base/format.html">format()</a></code> is your friend. It allows you to set the number of <code>digits</code> so you don’t print to a ridiculous degree of accuracy, and a <code>big.mark</code> to make numbers easier to read. You might combine these into a helper function:</p>
 | 
			
		||||
<div class="cell">
 | 
			
		||||
<pre data-type="programlisting" data-code-language="downlit">comma <- function(x) format(x, digits = 2, big.mark = ",")
 | 
			
		||||
comma(3452345)
 | 
			
		||||
@@ -423,7 +423,7 @@ Tables</h1>
 | 
			
		||||
#> Hornet 4 Drive    21.4   6  258 110 3.08 3.215 19.44  1  0    3    1
 | 
			
		||||
#> Hornet Sportabout 18.7   8  360 175 3.15 3.440 17.02  0  0    3    2</pre>
 | 
			
		||||
</div>
 | 
			
		||||
<p>If you prefer that data be displayed with additional formatting you can use the <code><a href="#chp-https://rdrr.io/pkg/knitr/man/kable" data-type="xref">#chp-https://rdrr.io/pkg/knitr/man/kable</a></code> function. The code below generates <a href="#tbl-kable" data-type="xref">#tbl-kable</a>.</p>
 | 
			
		||||
<p>If you prefer that data be displayed with additional formatting you can use the <code><a href="https://rdrr.io/pkg/knitr/man/kable.html">knitr::kable()</a></code> function. The code below generates <a href="#tbl-kable" data-type="xref">#tbl-kable</a>.</p>
 | 
			
		||||
<div class="cell">
 | 
			
		||||
<pre data-type="programlisting" data-code-language="downlit">knitr::kable(mtcars[1:5, ], )</pre>
 | 
			
		||||
<div class="cell-output-display">
 | 
			
		||||
@@ -504,7 +504,7 @@ Tables</h1>
 | 
			
		||||
</tr></tbody></table></div>
 | 
			
		||||
</div>
 | 
			
		||||
</div>
 | 
			
		||||
<p>Read the documentation for <code><a href="#chp-https://rdrr.io/pkg/knitr/man/kable" data-type="xref">#chp-https://rdrr.io/pkg/knitr/man/kable</a></code> to see the other ways in which you can customize the table. For even deeper customization, consider the <strong>gt</strong>, <strong>huxtable</strong>, <strong>reactable</strong>, <strong>kableExtra</strong>, <strong>xtable</strong>, <strong>stargazer</strong>, <strong>pander</strong>, <strong>tables</strong>, and <strong>ascii</strong> packages. Each provides a set of tools for returning formatted tables from R code.</p>
 | 
			
		||||
<p>Read the documentation for <code><a href="https://rdrr.io/pkg/knitr/man/kable.html">?knitr::kable</a></code> to see the other ways in which you can customize the table. For even deeper customization, consider the <strong>gt</strong>, <strong>huxtable</strong>, <strong>reactable</strong>, <strong>kableExtra</strong>, <strong>xtable</strong>, <strong>stargazer</strong>, <strong>pander</strong>, <strong>tables</strong>, and <strong>ascii</strong> packages. Each provides a set of tools for returning formatted tables from R code.</p>
 | 
			
		||||
<p>There is also a rich set of options for controlling how figures are embedded. You’ll learn about these in <a href="#chp-communicate-plots" data-type="xref">#chp-communicate-plots</a>.</p>
 | 
			
		||||
 | 
			
		||||
<section id="exercises-5" data-type="sect2">
 | 
			
		||||
@@ -559,20 +559,20 @@ processed_data <- rawdata |>
 | 
			
		||||
  mutate(new_variable = complicated_transformation(x, y, z))
 | 
			
		||||
```</code></pre>
 | 
			
		||||
<p><code>dependson</code> should contain a character vector of <em>every</em> chunk that the cached chunk depends on. Knitr will update the results for the cached chunk whenever it detects that one of its dependencies have changed.</p>
 | 
			
		||||
<p>Note that the chunks won’t update if <code>a_very_large_file.csv</code> changes, because knitr caching only tracks changes within the <code>.qmd</code> file. If you want to also track changes to that file you can use the <code>cache.extra</code> option. This is an arbitrary R expression that will invalidate the cache whenever it changes. A good function to use is <code><a href="#chp-https://rdrr.io/r/base/file.info" data-type="xref">#chp-https://rdrr.io/r/base/file.info</a></code>: it returns a bunch of information about the file including when it was last modified. Then you can write:</p>
 | 
			
		||||
<p>Note that the chunks won’t update if <code>a_very_large_file.csv</code> changes, because knitr caching only tracks changes within the <code>.qmd</code> file. If you want to also track changes to that file you can use the <code>cache.extra</code> option. This is an arbitrary R expression that will invalidate the cache whenever it changes. A good function to use is <code><a href="https://rdrr.io/r/base/file.info.html">file.info()</a></code>: it returns a bunch of information about the file including when it was last modified. Then you can write:</p>
 | 
			
		||||
<pre><code>```{r}
 | 
			
		||||
#| label: raw-data
 | 
			
		||||
#| cache.extra: file.info("a_very_large_file.csv")
 | 
			
		||||
 | 
			
		||||
rawdata <- readr::read_csv("a_very_large_file.csv")
 | 
			
		||||
```</code></pre>
 | 
			
		||||
<p>As your caching strategies get progressively more complicated, it’s a good idea to regularly clear out all your caches with <code><a href="#chp-https://rdrr.io/pkg/knitr/man/clean_cache" data-type="xref">#chp-https://rdrr.io/pkg/knitr/man/clean_cache</a></code>.</p>
 | 
			
		||||
<p>We’ve followed the advice of <a href="#chp-https://twitter.com/drob/status/738786604731490304" data-type="xref">#chp-https://twitter.com/drob/status/738786604731490304</a> to name these chunks: each chunk is named after the primary object that it creates. This makes it easier to understand the <code>dependson</code> specification.</p>
 | 
			
		||||
<p>As your caching strategies get progressively more complicated, it’s a good idea to regularly clear out all your caches with <code><a href="https://rdrr.io/pkg/knitr/man/clean_cache.html">knitr::clean_cache()</a></code>.</p>
 | 
			
		||||
<p>We’ve followed the advice of <a href="https://twitter.com/drob/status/738786604731490304">David Robinson</a> to name these chunks: each chunk is named after the primary object that it creates. This makes it easier to understand the <code>dependson</code> specification.</p>
 | 
			
		||||
 | 
			
		||||
<section id="exercises-6" data-type="sect2">
 | 
			
		||||
<h2>
 | 
			
		||||
Exercises</h2>
 | 
			
		||||
<ol type="1"><li>Set up a network of chunks where <code>d</code> depends on <code>c</code> and <code>b</code>, and both <code>b</code> and <code>c</code> depend on <code>a</code>. Have each chunk print <code><a href="#chp-https://lubridate.tidyverse.org/reference/now" data-type="xref">#chp-https://lubridate.tidyverse.org/reference/now</a></code>, set <code>cache: true</code>, then verify your understanding of caching.</li>
 | 
			
		||||
<ol type="1"><li>Set up a network of chunks where <code>d</code> depends on <code>c</code> and <code>b</code>, and both <code>b</code> and <code>c</code> depend on <code>a</code>. Have each chunk print <code><a href="https://lubridate.tidyverse.org/reference/now.html">lubridate::now()</a></code>, set <code>cache: true</code>, then verify your understanding of caching.</li>
 | 
			
		||||
</ol></section>
 | 
			
		||||
</section>
 | 
			
		||||
 | 
			
		||||
@@ -582,8 +582,8 @@ Troubleshooting</h1>
 | 
			
		||||
<p>Troubleshooting Quarto documents can be challenging because you are no longer in an interactive R environment, and you will need to learn some new tricks. Additionally, the error could be due to issues with the Quarto document itself or due to the R code in the Quarto document.</p>
 | 
			
		||||
<p>One common error in documents with code chunks is duplicated chunk labels, which are especially pervasive if your workflow involves copying and pasting code chunks. To address this issue, all you need to do is to change one of your duplicated labels.</p>
 | 
			
		||||
<p>If the errors are due to the R code in the document, the first thing you should always try is to recreate the problem in an interactive session. Restart R, then “Run all chunks” (either from Code menu, under Run region), or with the keyboard shortcut Ctrl + Alt + R. If you’re lucky, that will recreate the problem, and you can figure out what’s going on interactively.</p>
 | 
			
		||||
<p>If that doesn’t help, there must be something different between your interactive environment and the Quarto environment. You’re going to need to systematically explore the options. The most common difference is the working directory: the working directory of a Quarto is the directory in which it lives. Check the working directory is what you expect by including <code><a href="#chp-https://rdrr.io/r/base/getwd" data-type="xref">#chp-https://rdrr.io/r/base/getwd</a></code> in a chunk.</p>
 | 
			
		||||
<p>Next, brainstorm all the things that might cause the bug. You’ll need to systematically check that they’re the same in your R session and your Quarto session. The easiest way to do that is to set <code>error: true</code> on the chunk causing the problem, then use <code><a href="#chp-https://rdrr.io/r/base/print" data-type="xref">#chp-https://rdrr.io/r/base/print</a></code> and <code><a href="#chp-https://rdrr.io/r/utils/str" data-type="xref">#chp-https://rdrr.io/r/utils/str</a></code> to check that settings are as you expect.</p>
 | 
			
		||||
<p>If that doesn’t help, there must be something different between your interactive environment and the Quarto environment. You’re going to need to systematically explore the options. The most common difference is the working directory: the working directory of a Quarto is the directory in which it lives. Check the working directory is what you expect by including <code><a href="https://rdrr.io/r/base/getwd.html">getwd()</a></code> in a chunk.</p>
 | 
			
		||||
<p>Next, brainstorm all the things that might cause the bug. You’ll need to systematically check that they’re the same in your R session and your Quarto session. The easiest way to do that is to set <code>error: true</code> on the chunk causing the problem, then use <code><a href="https://rdrr.io/r/base/print.html">print()</a></code> and <code><a href="https://rdrr.io/r/utils/str.html">str()</a></code> to check that settings are as you expect.</p>
 | 
			
		||||
</section>
 | 
			
		||||
 | 
			
		||||
<section id="yaml-header" data-type="sect1">
 | 
			
		||||
@@ -645,9 +645,9 @@ ggplot(class, aes(displ, hwy)) +
 | 
			
		||||
Bibliographies and Citations</h2>
 | 
			
		||||
<p>Quarto can automatically generate citations and a bibliography in a number of styles. The most straightforward way of adding citations and bibliographies to a Quarto document is using the visual editor in RStudio.</p>
 | 
			
		||||
<p>To add a citation using the visual editor, go to Insert > Citation. Citations can be inserted from a variety of sources:</p>
 | 
			
		||||
<ol type="1"><li><p><a href="#citations-from-dois" data-type="xref">#citations-from-dois</a> (Document Object Identifier) references.</p></li>
 | 
			
		||||
<li><p><a href="#citations-from-zotero" data-type="xref">#citations-from-zotero</a> personal or group libraries.</p></li>
 | 
			
		||||
<li><p>Searches of <a href="#chp-https://www.crossref.org/" data-type="xref">#chp-https://www.crossref.org/</a>, <a href="#chp-https://datacite.org/" data-type="xref">#chp-https://datacite.org/</a>, or <a href="#chp-https://pubmed.ncbi.nlm.nih.gov/" data-type="xref">#chp-https://pubmed.ncbi.nlm.nih.gov/</a>.</p></li>
 | 
			
		||||
<ol type="1"><li><p><a href="https://quarto.org/docs/visual-editor/technical.html#citations-from-dois">DOI</a> (Document Object Identifier) references.</p></li>
 | 
			
		||||
<li><p><a href="https://quarto.org/docs/visual-editor/technical.html#citations-from-zotero">Zotero</a> personal or group libraries.</p></li>
 | 
			
		||||
<li><p>Searches of <a href="https://www.crossref.org/">Crossref</a>, <a href="https://datacite.org/">DataCite</a>, or <a href="https://pubmed.ncbi.nlm.nih.gov/">PubMed</a>.</p></li>
 | 
			
		||||
<li><p>Your document bibliography (a <code>.bib</code> file in the directory of your document)</p></li>
 | 
			
		||||
</ol><p>Under the hood, the visual mode uses the standard Pandoc markdown representation for citations (e.g. <code>[@citation]</code>).</p>
 | 
			
		||||
<p>If you add a citation using one of the first three methods, the visual editor will automatically create a <code>bibliography.bib</code> file for you and add the reference to it. It will also add a <code>bibliography</code> field to the document YAML. As you add more references, this file will get populated with their citations. You can also directly edit this file using many common bibliography formats including BibLaTeX, BibTeX, EndNote, Medline.</p>
 | 
			
		||||
@@ -675,7 +675,7 @@ csl: apa.csl</pre>
 | 
			
		||||
Learning more</h1>
 | 
			
		||||
<p>Quarto is still relatively young, and is still growing rapidly. The best place to stay on top of innovations is the official Quarto website: <a href="https://quarto.org/" class="uri">https://quarto.org</a>.</p>
 | 
			
		||||
<p>There are two important topics that we haven’t covered here: collaboration and the details of accurately communicating your ideas to other humans. Collaboration is a vital part of modern data science, and you can make your life much easier by using version control tools, like Git and GitHub. We recommend “Happy Git with R”, a user friendly introduction to Git and GitHub from R users, by Jenny Bryan. The book is freely available online: <a href="https://happygitwithr.com" class="uri">https://happygitwithr.com</a>.</p>
 | 
			
		||||
<p>We have also not touched on what you should actually write in order to clearly communicate the results of your analysis. To improve your writing, we highly recommend reading either <a href="#chp-https://www.amazon.com/Style-Lessons-Clarity-Grace-12th/dp/0134080416" data-type="xref">#chp-https://www.amazon.com/Style-Lessons-Clarity-Grace-12th/dp/0134080416</a> by Joseph M. Williams & Joseph Bizup, or <a href="#chp-https://www.amazon.com/Sense-Structure-Writing-Readers-Perspective/dp/0205296327" data-type="xref">#chp-https://www.amazon.com/Sense-Structure-Writing-Readers-Perspective/dp/0205296327</a> by George Gopen. Both books will help you understand the structure of sentences and paragraphs, and give you the tools to make your writing more clear. (These books are rather expensive if purchased new, but they’re used by many English classes so there are plenty of cheap second-hand copies). George Gopen also has a number of short articles on writing at <a href="https://www.georgegopen.com/the-litigation-articles.html" class="uri">https://www.georgegopen.com/the-litigation-articles.html</a>. They are aimed at lawyers, but almost everything applies to data scientists too.</p>
 | 
			
		||||
<p>We have also not touched on what you should actually write in order to clearly communicate the results of your analysis. To improve your writing, we highly recommend reading either <a href="https://www.amazon.com/Style-Lessons-Clarity-Grace-12th/dp/0134080416"><em>Style: Lessons in Clarity and Grace</em></a> by Joseph M. Williams & Joseph Bizup, or <a href="https://www.amazon.com/Sense-Structure-Writing-Readers-Perspective/dp/0205296327"><em>The Sense of Structure: Writing from the Reader’s Perspective</em></a> by George Gopen. Both books will help you understand the structure of sentences and paragraphs, and give you the tools to make your writing more clear. (These books are rather expensive if purchased new, but they’re used by many English classes so there are plenty of cheap second-hand copies). George Gopen also has a number of short articles on writing at <a href="https://www.georgegopen.com/the-litigation-articles.html" class="uri">https://www.georgegopen.com/the-litigation-articles.html</a>. They are aimed at lawyers, but almost everything applies to data scientists too.</p>
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
</section>
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user