Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Apply patches from the original web site #1

Merged
merged 2 commits into from
Nov 27, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion a2-packages.qmd
Original file line number Diff line number Diff line change
Expand Up @@ -57,5 +57,5 @@ Why does R make you bother with installing and loading packages? You can imagine

It is difficult to use an R package if you don't know that it exists. You could go to the CRAN website and click the Packages link to see a list of available packages, but you'll have to wade through thousands of them. Moreover, many R packages do the same things.

How do you know which package does them best? The R-packages [mailing list](http://stat.ethz.ch/mailman/listinfo/r-packages) is a place to start. It sends out announcements of new packages and maintains an archive of old announcements. Blogs that aggregate posts about R can also provide valuable leads. I recommend [R-bloggers](www.r-bloggers.com). RStudio maintains a list of some of the most useful R packages in the Getting Started section of <http://support.rstudio.com>. Finally, CRAN groups together some of the most useful---and most respected---packages by [subject area](http://cran.r-project.org/web/views). This is an excellent place to learn about the packages designed for your area of work.
How do you know which package does them best? The R-packages [mailing list](http://stat.ethz.ch/mailman/listinfo/r-packages) is a place to start. It sends out announcements of new packages and maintains an archive of old announcements. Blogs that aggregate posts about R can also provide valuable leads. I recommend [R-bloggers](https://www.r-bloggers.com). RStudio maintains a list of some of the most useful R packages in the Getting Started section of <http://support.rstudio.com>. Finally, CRAN groups together some of the most useful---and most respected---packages by [subject area](http://cran.r-project.org/web/views). This is an excellent place to learn about the packages designed for your area of work.
:::
2 changes: 1 addition & 1 deletion a4-data.qmd
Original file line number Diff line number Diff line change
Expand Up @@ -239,7 +239,7 @@ deck <- read.csv("https://gist.githubusercontent.com/garrettgman/9629323/raw/ee5

Just make sure that the web address links directly to the file and not to a web page that links to the file. Usually, when you visit a data file's web address, the file will begin to download or the raw data will appear in your browser window.

Note that websites that begin with \_<https://_> are secure websites, which means R may not be able to access the data provided at these links.
Note that websites that begin with \_https://\_ are secure websites, which means R may not be able to access the data provided at these links.

### Saving Plain-Text Files

Expand Down
4 changes: 2 additions & 2 deletions basics.qmd
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ You'll notice that a `[1]` appears next to your result. R is just letting you kn
> 100:130
[1] 100 101 102 103 104 105 106 107 108 109 110 111 112
[14] 113 114 115 116 117 118 119 120 121 122 123 124 125
[25] 126 127 128 129 130
[27] 126 127 128 129 130
```

::: callout-tip
Expand Down Expand Up @@ -626,4 +626,4 @@ As you've seen, R is a language that you can use to talk to your computer. You w

The two most important components of the R language are objects, which store data, and functions, which manipulate data. R also uses a host of operators like `+`, `-`, `*`, `/`, and `<-` to do basic tasks. As a data scientist, you will use R objects to store data in your computer's memory, and you will use functions to automate tasks and do complicated calculations. We will examine objects in more depth later in [Project 2: Playing Cards](#sec-project-cards) and dig further into functions in [Project 3: Slot Machine](#sec-project-slots). The vocabulary you have developed here will make each of those projects easier to understand. However, we're not done with your dice yet.

In [Packages and Help Pages](#sec-packages-and-help), you'll run some simulations on your dice and build your first graphs in R. You'll also look at two of the most useful components of the R language: R *packages*, which are collections of functions writted by R's talented community of developers, and R documentation, which is a collection of help pages built into R that explains every function and data set in the language.
In [Packages and Help Pages](#sec-packages-and-help), you'll run some simulations on your dice and build your first graphs in R. You'll also look at two of the most useful components of the R language: R *packages*, which are collections of functions written by R's talented community of developers, and R documentation, which is a collection of help pages built into R that explains every function and data set in the language.
2 changes: 1 addition & 1 deletion dice.qmd
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ Believe it or not, R can help you do that. Over the course of the book, you will

These projects are lighthearted, but they are also deep. As you complete them, you will become an expert at the skills you need to work with data as a data scientist. You will learn how to store data in your computer's memory, how to access data that is already there, and how to transform data values in memory when necessary. You will also learn how to write your own programs in R that you can use to analyze data and run simulations.

If simulating a slot machine (or dice, or cards) seems frivilous, think of it this way: playing a slot machine is a process. Once you can simulate it, you'll be able to simulate other processes, such as bootstrap sampling, Markov chain Monte Carlo, and other data-analysis procedures. Plus, these projects provide concrete examples for learning all of the components of R programming: objects, data types, classes, notation, functions, environments, `if` trees, loops, and vectorization. This first project will make it easier to study these things by teaching you the basics of R.
If simulating a slot machine (or dice, or cards) seems frivolous, think of it this way: playing a slot machine is a process. Once you can simulate it, you'll be able to simulate other processes, such as bootstrap sampling, Markov chain Monte Carlo, and other data-analysis procedures. Plus, these projects provide concrete examples for learning all of the components of R programming: objects, data types, classes, notation, functions, environments, `if` trees, loops, and vectorization. This first project will make it easier to study these things by teaching you the basics of R.

Your first mission is simple: assemble R code that will simulate rolling a pair of dice, like at a craps table. Once you have done that, we'll weight the dice a bit in your favor, just to keep things interesting.

Expand Down
2 changes: 1 addition & 1 deletion docs/a2-packages.html
Original file line number Diff line number Diff line change
Expand Up @@ -394,7 +394,7 @@ <h2 data-number="B.2" class="anchored" data-anchor-id="loading-packages"><span c
</div>
<div class="callout-body-container callout-body">
<p>It is difficult to use an R package if you don’t know that it exists. You could go to the CRAN website and click the Packages link to see a list of available packages, but you’ll have to wade through thousands of them. Moreover, many R packages do the same things.</p>
<p>How do you know which package does them best? The R-packages <a href="http://stat.ethz.ch/mailman/listinfo/r-packages">mailing list</a> is a place to start. It sends out announcements of new packages and maintains an archive of old announcements. Blogs that aggregate posts about R can also provide valuable leads. I recommend <a href="www.r-bloggers.com">R-bloggers</a>. RStudio maintains a list of some of the most useful R packages in the Getting Started section of <a href="http://support.rstudio.com" class="uri">http://support.rstudio.com</a>. Finally, CRAN groups together some of the most useful—and most respected—packages by <a href="http://cran.r-project.org/web/views">subject area</a>. This is an excellent place to learn about the packages designed for your area of work.</p>
<p>How do you know which package does them best? The R-packages <a href="http://stat.ethz.ch/mailman/listinfo/r-packages">mailing list</a> is a place to start. It sends out announcements of new packages and maintains an archive of old announcements. Blogs that aggregate posts about R can also provide valuable leads. I recommend <a href="https://www.r-bloggers.com">R-bloggers</a>. RStudio maintains a list of some of the most useful R packages in the Getting Started section of <a href="http://support.rstudio.com" class="uri">http://support.rstudio.com</a>. Finally, CRAN groups together some of the most useful—and most respected—packages by <a href="http://cran.r-project.org/web/views">subject area</a>. This is an excellent place to learn about the packages designed for your area of work.</p>
</div>
</div>

Expand Down
2 changes: 1 addition & 1 deletion docs/a4-data.html
Original file line number Diff line number Diff line change
Expand Up @@ -557,7 +557,7 @@ <h3 data-number="D.3.4" class="anchored" data-anchor-id="html-links"><span class
<p>That’s obviously not a real address, but here’s something that would work—if you can manage to type it!</p>
<div class="sourceCode" id="cb19"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb19-1"><a href="#cb19-1" aria-hidden="true" tabindex="-1"></a>deck <span class="ot">&lt;-</span> <span class="fu">read.csv</span>(<span class="st">"https://gist.githubusercontent.com/garrettgman/9629323/raw/ee5dfc039fd581cb467cc69c226ea2524913c3d8/deck.csv"</span>)</span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
<p>Just make sure that the web address links directly to the file and not to a web page that links to the file. Usually, when you visit a data file’s web address, the file will begin to download or the raw data will appear in your browser window.</p>
<p>Note that websites that begin with _<a href="https://_" class="uri">https://_</a> are secure websites, which means R may not be able to access the data provided at these links.</p>
<p>Note that websites that begin with _https://_ are secure websites, which means R may not be able to access the data provided at these links.</p>
</section>
<section id="saving-plain-text-files" class="level3" data-number="D.3.5">
<h3 data-number="D.3.5" class="anchored" data-anchor-id="saving-plain-text-files"><span class="header-section-number">D.3.5</span> Saving Plain-Text Files</h3>
Expand Down
4 changes: 2 additions & 2 deletions docs/basics.html
Original file line number Diff line number Diff line change
Expand Up @@ -384,7 +384,7 @@ <h2 data-number="1.1" class="anchored" data-anchor-id="the-r-user-interface"><sp
<div class="sourceCode" id="cb2"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb2-1"><a href="#cb2-1" aria-hidden="true" tabindex="-1"></a><span class="sc">&gt;</span> <span class="dv">100</span><span class="sc">:</span><span class="dv">130</span></span>
<span id="cb2-2"><a href="#cb2-2" aria-hidden="true" tabindex="-1"></a> [<span class="dv">1</span>] <span class="dv">100</span> <span class="dv">101</span> <span class="dv">102</span> <span class="dv">103</span> <span class="dv">104</span> <span class="dv">105</span> <span class="dv">106</span> <span class="dv">107</span> <span class="dv">108</span> <span class="dv">109</span> <span class="dv">110</span> <span class="dv">111</span> <span class="dv">112</span></span>
<span id="cb2-3"><a href="#cb2-3" aria-hidden="true" tabindex="-1"></a>[<span class="dv">14</span>] <span class="dv">113</span> <span class="dv">114</span> <span class="dv">115</span> <span class="dv">116</span> <span class="dv">117</span> <span class="dv">118</span> <span class="dv">119</span> <span class="dv">120</span> <span class="dv">121</span> <span class="dv">122</span> <span class="dv">123</span> <span class="dv">124</span> <span class="dv">125</span></span>
<span id="cb2-4"><a href="#cb2-4" aria-hidden="true" tabindex="-1"></a>[<span class="dv">25</span>] <span class="dv">126</span> <span class="dv">127</span> <span class="dv">128</span> <span class="dv">129</span> <span class="dv">130</span></span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
<span id="cb2-4"><a href="#cb2-4" aria-hidden="true" tabindex="-1"></a>[<span class="dv">27</span>] <span class="dv">126</span> <span class="dv">127</span> <span class="dv">128</span> <span class="dv">129</span> <span class="dv">130</span></span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
<div class="callout-tip callout callout-style-default callout-captioned">
<div class="callout-header d-flex align-content-center">
<div class="callout-icon-container">
Expand Down Expand Up @@ -899,7 +899,7 @@ <h2 data-number="1.7" class="anchored" data-anchor-id="summary"><span class="hea
<p>You’ve covered a lot of ground already. You now have a virtual die stored in your computer’s memory, as well as your own R function that rolls a pair of dice. You’ve also begun speaking the R language.</p>
<p>As you’ve seen, R is a language that you can use to talk to your computer. You write commands in R and run them at the command line for your computer to read. Your computer will sometimes talk back–for example, when you commit an error–but it usually just does what you ask and then displays the result.</p>
<p>The two most important components of the R language are objects, which store data, and functions, which manipulate data. R also uses a host of operators like <code>+</code>, <code>-</code>, <code>*</code>, <code>/</code>, and <code>&lt;-</code> to do basic tasks. As a data scientist, you will use R objects to store data in your computer’s memory, and you will use functions to automate tasks and do complicated calculations. We will examine objects in more depth later in <a href="cards.html">Project 2: Playing Cards</a> and dig further into functions in <a href="slots.html">Project 3: Slot Machine</a>. The vocabulary you have developed here will make each of those projects easier to understand. However, we’re not done with your dice yet.</p>
<p>In <a href="packages.html">Packages and Help Pages</a>, you’ll run some simulations on your dice and build your first graphs in R. You’ll also look at two of the most useful components of the R language: R <em>packages</em>, which are collections of functions writted by R’s talented community of developers, and R documentation, which is a collection of help pages built into R that explains every function and data set in the language.</p>
<p>In <a href="packages.html">Packages and Help Pages</a>, you’ll run some simulations on your dice and build your first graphs in R. You’ll also look at two of the most useful components of the R language: R <em>packages</em>, which are collections of functions written by R’s talented community of developers, and R documentation, which is a collection of help pages built into R that explains every function and data set in the language.</p>


</section>
Expand Down
2 changes: 1 addition & 1 deletion docs/dice.html
Original file line number Diff line number Diff line change
Expand Up @@ -281,7 +281,7 @@ <h1 class="title"><span id="sec-project-dice" class="quarto-section-identifier d
<p>When I was a college student, I sometimes daydreamed of going to Las Vegas. I thought that knowing statistics might help me win big. If that’s what led <em>you</em> to data science, you better sit down; I have some bad news. Even a statistician will lose money in a casino over the long run. This is because the odds for each game are always stacked in the casino’s favor. However, there is a loophole to this rule. You can make money–and reliably too. All you have to do is <em>be the casino</em>.</p>
<p>Believe it or not, R can help you do that. Over the course of the book, you will use R to build three virtual objects: a pair of dice that you can roll to generate random numbers, a deck of cards that you can shuffle and deal from, and a slot machine modeled after some real-life video lottery terminals. After that, you’ll just need to add some video graphics and a bank account (and maybe get a few government licenses), and you’ll be in business. I’ll leave those details to you.</p>
<p>These projects are lighthearted, but they are also deep. As you complete them, you will become an expert at the skills you need to work with data as a data scientist. You will learn how to store data in your computer’s memory, how to access data that is already there, and how to transform data values in memory when necessary. You will also learn how to write your own programs in R that you can use to analyze data and run simulations.</p>
<p>If simulating a slot machine (or dice, or cards) seems frivilous, think of it this way: playing a slot machine is a process. Once you can simulate it, you’ll be able to simulate other processes, such as bootstrap sampling, Markov chain Monte Carlo, and other data-analysis procedures. Plus, these projects provide concrete examples for learning all of the components of R programming: objects, data types, classes, notation, functions, environments, <code>if</code> trees, loops, and vectorization. This first project will make it easier to study these things by teaching you the basics of R.</p>
<p>If simulating a slot machine (or dice, or cards) seems frivolous, think of it this way: playing a slot machine is a process. Once you can simulate it, you’ll be able to simulate other processes, such as bootstrap sampling, Markov chain Monte Carlo, and other data-analysis procedures. Plus, these projects provide concrete examples for learning all of the components of R programming: objects, data types, classes, notation, functions, environments, <code>if</code> trees, loops, and vectorization. This first project will make it easier to study these things by teaching you the basics of R.</p>
<p>Your first mission is simple: assemble R code that will simulate rolling a pair of dice, like at a craps table. Once you have done that, we’ll weight the dice a bit in your favor, just to keep things interesting.</p>
<p>In this project, you will learn how to:</p>
<ul>
Expand Down
2 changes: 1 addition & 1 deletion docs/environments.html
Original file line number Diff line number Diff line change
Expand Up @@ -605,7 +605,7 @@ <h2 data-number="6.5" class="anchored" data-anchor-id="evaluation"><span class="
<span id="cb21-16"><a href="#cb21-16" aria-hidden="true" tabindex="-1"></a><span class="do">## $objects</span></span>
<span id="cb21-17"><a href="#cb21-17" aria-hidden="true" tabindex="-1"></a><span class="do">## x : chr "take me to your runtime"</span></span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
<p>Let’s put this all together to see how R evaluates a function. Before you call a function, R is working in an active environment; let’s call this the <em>calling environment</em>. It is the environment R calls the function from.</p>
<p>Then you call the function. R responds by setting up a new runtime environment. This environment will be a child of the function’s origin enviornment. R will copy each of the function’s arguments into the runtime environment and then make the runtime environment the new active environment.</p>
<p>Then you call the function. R responds by setting up a new runtime environment. This environment will be a child of the function’s origin environment. R will copy each of the function’s arguments into the runtime environment and then make the runtime environment the new active environment.</p>
<p>Next, R runs the code in the body of the function. If the code creates any objects, R stores them in the active, that is, runtime environment. If the code calls any objects, R uses its scoping rules to look them up. R will search the runtime environment, then the parent of the runtime environment (which will be the origin environment), then the parent of the origin environment, and so on. Notice that the calling environment might not be on the search path. Usually, a function will only call its arguments, which R can find in the active runtime environment.</p>
<p>Finally, R finishes running the function. It switches the active environment back to the calling environment. Now R executes any other commands in the line of code that called the function. So if you save the result of the function to an object with <code>&lt;-</code>, the new object will be stored in the calling environment.</p>
<p>To recap, R stores its objects in an environment system. At any moment of time, R is working closely with a single active environment. It stores new objects in this environment, and it uses the environment as a starting point when it searches for existing objects. R’s active environment is usually the global environment, but R will adjust the active environment to do things like run functions in a safe manner.</p>
Expand Down
Loading