Don't transform non-crossref links

This commit is contained in:
Hadley Wickham
2022-11-18 10:30:32 -06:00
parent 4caea5281b
commit 78a1c12fe7
32 changed files with 693 additions and 693 deletions

View File

@@ -39,7 +39,7 @@ not_cancelled |>
summarize(mean = mean(dep_delay))</pre>
</div>
<p>Instead of running your code expression-by-expression, you can also execute the complete script in one step with Cmd/Ctrl + Shift + S. Doing this regularly is a great way to ensure that youve captured all the important parts of your code in the script.</p>
<p>We recommend that you always start your script with the packages that you need. That way, if you share your code with others, they can easily see which packages they need to install. Note, however, that you should never include <code><a href="#chp-https://rdrr.io/r/utils/install.packages" data-type="xref">#chp-https://rdrr.io/r/utils/install.packages</a></code> in a script that you share. Its very antisocial to change settings on someone elses computer!</p>
<p>We recommend that you always start your script with the packages that you need. That way, if you share your code with others, they can easily see which packages they need to install. Note, however, that you should never include <code><a href="https://rdrr.io/r/utils/install.packages.html">install.packages()</a></code> in a script that you share. Its very antisocial to change settings on someone elses computer!</p>
<p>When working through future chapters, we highly recommend starting in the script editor and practicing your keyboard shortcuts. Over time, sending code to the console in this way will become so natural that you wont even think about it.</p>
</section>
@@ -84,7 +84,7 @@ Figure_02.png
model_first_try.R
run-first.r
temp.txt</code></pre>
<p>There are a variety of problems here: its hard to find which file to run first, file names contain spaces, there are two files with the same name but different capitalization (<code>finalreport</code> vs. <code>FinalReport</code><span data-type="footnote">Not to mention that youre tempting fate by using “final” in the name 😆 The comic piled higher and deeper has a <a href="#chp-https://phdcomics.com/comics/archive.php?comicid=1531" data-type="xref">#chp-https://phdcomics.com/comics/archive.php?comicid=1531</a>.</span>), and some names dont describe their contents (<code>run-first</code> and <code>temp</code>).</p>
<p>There are a variety of problems here: its hard to find which file to run first, file names contain spaces, there are two files with the same name but different capitalization (<code>finalreport</code> vs. <code>FinalReport</code><span data-type="footnote">Not to mention that youre tempting fate by using “final” in the name 😆 The comic piled higher and deeper has a <a href="https://phdcomics.com/comics/archive.php?comicid=1531">fun strip on this</a>.</span>), and some names dont describe their contents (<code>run-first</code> and <code>temp</code>).</p>
<p>Heres better way of naming and organizing the same set of files:</p>
<pre><code>01-load-data.R
02-exploratory-analysis.R
@@ -111,7 +111,7 @@ Projects</h1>
<h2>
What is the source of truth?</h2>
<p>As a beginning R user, its OK to consider your environment (i.e. the objects listed in the environment pane) to be your analysis. However, in the long run, youll be much better off if you ensure that your R scripts are the source of truth. With your R scripts (and your data files), you can recreate the environment. With only your environment, its much harder to recreate your R scripts: youll either have to retype a lot of code from memory (inevitably making mistakes along the way) or youll have to carefully mine your R history.</p>
<p>To help keep your R scripts as the source of truth for your analysis, we highly recommend that you instruct RStudio not to preserve your workspace between sessions. You can do this either by running <code><a href="#chp-https://usethis.r-lib.org/reference/use_blank_slate" data-type="xref">#chp-https://usethis.r-lib.org/reference/use_blank_slate</a></code><span data-type="footnote">If you dont have usethis installed, you can install it with <code>install.packages("usethis")</code>.</span> or by mimicking the options shown in <a href="#fig-blank-slate" data-type="xref">#fig-blank-slate</a>. This will cause you some short-term pain, because now when you restart RStudio, it will no longer remember the code that you ran last time. But this short-term pain saves you long-term agony because it forces you to capture all important interactions in your code. Theres nothing worse than discovering three months after the fact that youve only stored the results of an important calculation in your workspace, not the calculation itself in your code.</p>
<p>To help keep your R scripts as the source of truth for your analysis, we highly recommend that you instruct RStudio not to preserve your workspace between sessions. You can do this either by running <code><a href="https://usethis.r-lib.org/reference/use_blank_slate.html">usethis::use_blank_slate()</a></code><span data-type="footnote">If you dont have usethis installed, you can install it with <code>install.packages("usethis")</code>.</span> or by mimicking the options shown in <a href="#fig-blank-slate" data-type="xref">#fig-blank-slate</a>. This will cause you some short-term pain, because now when you restart RStudio, it will no longer remember the code that you ran last time. But this short-term pain saves you long-term agony because it forces you to capture all important interactions in your code. Theres nothing worse than discovering three months after the fact that youve only stored the results of an important calculation in your workspace, not the calculation itself in your code.</p>
<div class="cell">
<div class="cell-output-display">
@@ -141,7 +141,7 @@ Where does your analysis live?</h2>
<p><img src="screenshots/rstudio-wd.png" alt="The Console tab shows the current working directory as ~/Documents/r4ds/r4ds. " width="321"/></p>
</div>
</div>
<p>And you can print this out in R code by running <code><a href="#chp-https://rdrr.io/r/base/getwd" data-type="xref">#chp-https://rdrr.io/r/base/getwd</a></code>:</p>
<p>And you can print this out in R code by running <code><a href="https://rdrr.io/r/base/getwd.html">getwd()</a></code>:</p>
<div class="cell">
<pre data-type="programlisting" data-code-language="downlit">getwd()
#&gt; [1] "/Users/hadley/Documents/r4ds/r4ds"</pre>