Fix code language

This commit is contained in:
Hadley Wickham
2022-11-18 11:26:25 -06:00
parent 69b4597f3b
commit 868a35ca71
29 changed files with 912 additions and 907 deletions

View File

@@ -131,13 +131,13 @@ Where does your analysis live?</h2>
</div>
<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()
<pre data-type="programlisting" data-code-language="r">getwd()
#&gt; [1] "/Users/hadley/Documents/r4ds/r4ds"</pre>
</div>
<p>As a beginning R user, its OK to let your working direction be your home directory, documents directory, or any other weird directory on your computer. But youre nine chapters into this book, and youre no longer a rank beginner. Very soon now you should evolve to organizing your projects into directories and, when working on a project, set Rs working directory to the associated directory.</p>
<p>You can set the working directory from within R but <strong>we</strong> <strong>do not recommend it</strong>:</p>
<div class="cell">
<pre data-type="programlisting" data-code-language="downlit">setwd("/path/to/my/CoolProject")</pre>
<pre data-type="programlisting" data-code-language="r">setwd("/path/to/my/CoolProject")</pre>
</div>
<p>Theres a better way; a way that also puts you on the path to managing your R work like an expert. That way is the <strong>RStudio</strong> <strong>project</strong>.</p>
</section>
@@ -170,12 +170,12 @@ RStudio projects</h2>
<p>Call your project <code>r4ds</code> and think carefully about which subdirectory you put the project in. If you dont store it somewhere sensible, it will be hard to find it in the future!</p>
<p>Once this process is complete, youll get a new RStudio project just for this book. Check that the “home” of your project is the current working directory:</p>
<div class="cell">
<pre data-type="programlisting" data-code-language="downlit">getwd()
<pre data-type="programlisting" data-code-language="r">getwd()
#&gt; [1] /Users/hadley/Documents/r4ds/r4ds</pre>
</div>
<p>Now enter the following commands in the script editor, and save the file, calling it “diamonds.R”. Next, run the complete script which will save a PDF and CSV file into your project directory. Dont worry about the details, youll learn them later in the book.</p>
<div class="cell">
<pre data-type="programlisting" data-code-language="downlit">library(tidyverse)
<pre data-type="programlisting" data-code-language="r">library(tidyverse)
ggplot(diamonds, aes(carat, price)) +
geom_hex()