Fix code language
This commit is contained in:
@@ -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()
|
||||
#> [1] "/Users/hadley/Documents/r4ds/r4ds"</pre>
|
||||
</div>
|
||||
<p>As a beginning R user, it’s OK to let your working direction be your home directory, documents directory, or any other weird directory on your computer. But you’re nine chapters into this book, and you’re no longer a rank beginner. Very soon now you should evolve to organizing your projects into directories and, when working on a project, set R’s 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>There’s 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 don’t store it somewhere sensible, it will be hard to find it in the future!</p>
|
||||
<p>Once this process is complete, you’ll 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()
|
||||
#> [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. Don’t worry about the details, you’ll 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()
|
||||
|
||||
Reference in New Issue
Block a user