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

Fix typos in README and book #2

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
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 README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ Currently, there are three branches:

* `bookdown`: used to build the Bookdown version of the book

* `leanpub`: sued to build the Leanpub version of the book
* `leanpub`: used to build the Leanpub version of the book


### Before You Start
Expand Down
10 changes: 5 additions & 5 deletions manuscript/apply.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ x <- 1:4
lapply(x, runif, min = 0, max = 10)
```

So now, instead of the random numbers being between 0 and 1 (the default), the are all between 0 and 10.
So now, instead of the random numbers being between 0 and 1 (the default), they are all between 0 and 10.

The `lapply()` function and its friends make heavy use of _anonymous_ functions. Anonymous functions are like members of [Project Mayhem](http://en.wikipedia.org/wiki/Fight_Club)---they have no names. These are functions are generated "on the fly" as you are using `lapply()`. Once the call to `lapply()` is finished, the function disappears and does not appear in the workspace.

Expand Down Expand Up @@ -165,7 +165,7 @@ where
- `f` is a factor (or coerced to one) or a list of factors
- `drop` indicates whether empty factors levels should be dropped

The combination of `split()` and a function like `lapply()` or `sapply()` is a common paradigm in R. The basic idea is that you can take a data structure, split it into subsets defined by another variable, and apply a function over those subsets. The results of applying tha function over the subsets are then collated and returned as an object. This sequence of operations is sometimes referred to as "map-reduce" in other contexts.
The combination of `split()` and a function like `lapply()` or `sapply()` is a common paradigm in R. The basic idea is that you can take a data structure, split it into subsets defined by another variable, and apply a function over those subsets. The results of applying the function over the subsets are then collated and returned as an object. This sequence of operations is sometimes referred to as "map-reduce" in other contexts.

Here we simulate some data and split it according to a factor variable. Note that we use the `gl()` function to "generate levels" in a factor variable.

Expand Down Expand Up @@ -413,13 +413,13 @@ With `mapply()`, instead we can do
This passes the sequence `1:4` to the first argument of `rep()` and the sequence `4:1` to the second argument.


Here's another example for simulating randon Normal variables.
Here's another example for simulating random Normal variables.

```{r}
noise <- function(n, mean, sd) {
rnorm(n, mean, sd)
}
## Simulate 5 randon numbers
## Simulate 5 random numbers
noise(5, 1, 2)

## This only simulates 1 set of numbers, not 5
Expand All @@ -443,7 +443,7 @@ list(noise(1, 1, 2), noise(2, 2, 2),

## Vectorizing a Function

The `mapply()` function can be use to automatically "vectorize" a function. What this means is that it can be used to take a function that typically only takes single arguments and create a new function that can take vector arguments. This is often needed when you want to plot functions.
The `mapply()` function can be used to automatically "vectorize" a function. What this means is that it can be used to take a function that typically only takes single arguments and create a new function that can take vector arguments. This is often needed when you want to plot functions.

Here's an example of a function that computes the sum of squares given some data, a mean parameter and a standard deviation. The formula is $\sum_{i=1}^n(x_i-\mu)^2/\sigma^2$.

Expand Down
10 changes: 5 additions & 5 deletions manuscript/apply.md
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ Here, the `min = 0` and `max = 10` arguments are passed down to `runif()` every
[1] 0.9916910 1.1890256 0.5043966 9.2925392
~~~~~~~~

So now, instead of the random numbers being between 0 and 1 (the default), the are all between 0 and 10.
So now, instead of the random numbers being between 0 and 1 (the default), they are all between 0 and 10.

The `lapply()` function and its friends make heavy use of _anonymous_ functions. Anonymous functions are like members of [Project Mayhem](http://en.wikipedia.org/wiki/Fight_Club)---they have no names. These are functions are generated "on the fly" as you are using `lapply()`. Once the call to `lapply()` is finished, the function disappears and does not appear in the workspace.

Expand Down Expand Up @@ -265,7 +265,7 @@ where
- `f` is a factor (or coerced to one) or a list of factors
- `drop` indicates whether empty factors levels should be dropped

The combination of `split()` and a function like `lapply()` or `sapply()` is a common paradigm in R. The basic idea is that you can take a data structure, split it into subsets defined by another variable, and apply a function over those subsets. The results of applying tha function over the subsets are then collated and returned as an object. This sequence of operations is sometimes referred to as "map-reduce" in other contexts.
The combination of `split()` and a function like `lapply()` or `sapply()` is a common paradigm in R. The basic idea is that you can take a data structure, split it into subsets defined by another variable, and apply a function over those subsets. The results of applying the function over the subsets are then collated and returned as an object. This sequence of operations is sometimes referred to as "map-reduce" in other contexts.

Here we simulate some data and split it according to a factor variable. Note that we use the `gl()` function to "generate levels" in a factor variable.

Expand Down Expand Up @@ -732,15 +732,15 @@ With `mapply()`, instead we can do
This passes the sequence `1:4` to the first argument of `rep()` and the sequence `4:1` to the second argument.


Here's another example for simulating randon Normal variables.
Here's another example for simulating random Normal variables.


{line-numbers=off}
~~~~~~~~
> noise <- function(n, mean, sd) {
+ rnorm(n, mean, sd)
+ }
> ## Simulate 5 randon numbers
> ## Simulate 5 random numbers
> noise(5, 1, 2)
[1] -0.5196913 3.2979182 -0.6849525 1.7828267 2.7827545
>
Expand Down Expand Up @@ -798,7 +798,7 @@ The above call to `mapply()` is the same as

## Vectorizing a Function

The `mapply()` function can be use to automatically "vectorize" a function. What this means is that it can be used to take a function that typically only takes single arguments and create a new function that can take vector arguments. This is often needed when you want to plot functions.
The `mapply()` function can be used to automatically "vectorize" a function. What this means is that it can be used to take a function that typically only takes single arguments and create a new function that can take vector arguments. This is often needed when you want to plot functions.

Here's an example of a function that computes the sum of squares given some data, a mean parameter and a standard deviation. The formula is {$$}\sum_{i=1}^n(x_i-\mu)^2/\sigma^2{/$$}.

Expand Down
6 changes: 3 additions & 3 deletions manuscript/control.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,10 @@ Commonly used control structures are

- `break`: break the execution of a loop

- `next`: skip an interation of a loop
- `next`: skip an iteration of a loop

Most control structures are not used in interactive sessions, but
rather when writing functions or longer expresisons. However, these
rather when writing functions or longer expressions. However, these
constructs do not have to be used in functions and it's a good idea to
become familiar with them before we delve into functions.

Expand Down Expand Up @@ -259,7 +259,7 @@ not commonly used in statistical or data analysis applications but
they do have their uses. The only way to exit a `repeat` loop is to
call `break`.

One possible paradigm might be in an iterative algorith where you may
One possible paradigm might be in an iterative algorithm where you may
be searching for a solution and you don't want to stop until you're
close enough to the solution. In this kind of situation, you often
don't know in advance how many iterations it's going to take to get
Expand Down
6 changes: 3 additions & 3 deletions manuscript/control.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,10 @@ Commonly used control structures are

- `break`: break the execution of a loop

- `next`: skip an interation of a loop
- `next`: skip an iteration of a loop

Most control structures are not used in interactive sessions, but
rather when writing functions or longer expresisons. However, these
rather when writing functions or longer expressions. However, these
constructs do not have to be used in functions and it's a good idea to
become familiar with them before we delve into functions.

Expand Down Expand Up @@ -317,7 +317,7 @@ not commonly used in statistical or data analysis applications but
they do have their uses. The only way to exit a `repeat` loop is to
call `break`.

One possible paradigm might be in an iterative algorith where you may
One possible paradigm might be in an iterative algorithm where you may
be searching for a solution and you don't want to stop until you're
close enough to the solution. In this kind of situation, you often
don't know in advance how many iterations it's going to take to get
Expand Down
2 changes: 1 addition & 1 deletion manuscript/debugging.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -269,7 +269,7 @@ Enter a frame number, or 0 to exit
Selection:
```

The `recover()` function will first print out the function call stack when an error occurrs. Then, you can choose to jump around the call stack and investigate the problem. When you choose a frame number, you will be put in the browser (just like the interactive debugger triggered with `debug()`) and will have the ability to poke around.
The `recover()` function will first print out the function call stack when an error occurs. Then, you can choose to jump around the call stack and investigate the problem. When you choose a frame number, you will be put in the browser (just like the interactive debugger triggered with `debug()`) and will have the ability to poke around.

## Summary

Expand Down
2 changes: 1 addition & 1 deletion manuscript/debugging.md
Original file line number Diff line number Diff line change
Expand Up @@ -305,7 +305,7 @@ Enter a frame number, or 0 to exit
Selection:
~~~~~~~~

The `recover()` function will first print out the function call stack when an error occurrs. Then, you can choose to jump around the call stack and investigate the problem. When you choose a frame number, you will be put in the browser (just like the interactive debugger triggered with `debug()`) and will have the ability to poke around.
The `recover()` function will first print out the function call stack when an error occurs. Then, you can choose to jump around the call stack and investigate the problem. When you choose a frame number, you will be put in the browser (just like the interactive debugger triggered with `debug()`) and will have the ability to poke around.

## Summary

Expand Down
2 changes: 1 addition & 1 deletion manuscript/dplyr.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,7 @@ Here you can see the names of the first five variables in the `chicago` data fra
head(chicago[, 1:5], 3)
```

The `dptp` column is supposed to represent the dew point temperature adn the `pm25tmean2` column provides the PM2.5 data. However, these names are pretty obscure or awkward and probably be renamed to something more sensible.
The `dptp` column is supposed to represent the dew point temperature and the `pm25tmean2` column provides the PM2.5 data. However, these names are pretty obscure or awkward and probably be renamed to something more sensible.

```{r}
chicago <- rename(chicago, dewpoint = dptp, pm25 = pm25tmean2)
Expand Down
2 changes: 1 addition & 1 deletion manuscript/dplyr.md
Original file line number Diff line number Diff line change
Expand Up @@ -339,7 +339,7 @@ Here you can see the names of the first five variables in the `chicago` data fra
3 chic 35 29.4 2005-12-29 7.45000
~~~~~~~~

The `dptp` column is supposed to represent the dew point temperature adn the `pm25tmean2` column provides the PM2.5 data. However, these names are pretty obscure or awkward and probably be renamed to something more sensible.
The `dptp` column is supposed to represent the dew point temperature and the `pm25tmean2` column provides the PM2.5 data. However, these names are pretty obscure or awkward and probably be renamed to something more sensible.


{line-numbers=off}
Expand Down
4 changes: 2 additions & 2 deletions manuscript/functions.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ f()

The last aspect of a basic function is the *function arguments*. These
are the options that you can specify to the user that the user may
explicity set. For this basic function, we can add an argument that
explicitly set. For this basic function, we can add an argument that
determines how many times "Hello, world!" is printed to the console.

```{r}
Expand Down Expand Up @@ -98,7 +98,7 @@ print(meaningoflife)

In the above function, we didn't have to indicate anything special in order for the function to return the number of characters. In R, the return value of a function is always the very last expression that is evaluated. Because the `chars` variable is the last expression that is evaluated in this function, that becomes the return value of the function.

Note that there is a `return()` function that can be used to return an explicity value from a function, but it is rarely used in R (we will discuss it a bit later in this chapter).
Note that there is a `return()` function that can be used to return an explicit value from a function, but it is rarely used in R (we will discuss it a bit later in this chapter).

Finally, in the above function, the user must specify the value of the argument `num`. If it is not specified by the user, R will throw an error.

Expand Down
4 changes: 2 additions & 2 deletions manuscript/functions.md
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ Hello, world!

The last aspect of a basic function is the *function arguments*. These
are the options that you can specify to the user that the user may
explicity set. For this basic function, we can add an argument that
explicitly set. For this basic function, we can add an argument that
determines how many times "Hello, world!" is printed to the console.


Expand Down Expand Up @@ -114,7 +114,7 @@ Hello, world!

In the above function, we didn't have to indicate anything special in order for the function to return the number of characters. In R, the return value of a function is always the very last expression that is evaluated. Because the `chars` variable is the last expression that is evaluated in this function, that becomes the return value of the function.

Note that there is a `return()` function that can be used to return an explicity value from a function, but it is rarely used in R (we will discuss it a bit later in this chapter).
Note that there is a `return()` function that can be used to return an explicit value from a function, but it is rarely used in R (we will discuss it a bit later in this chapter).

Finally, in the above function, the user must specify the value of the argument `num`. If it is not specified by the user, R will throw an error.

Expand Down
2 changes: 1 addition & 1 deletion manuscript/overview.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -281,7 +281,7 @@ with Douglas Bates and Brian Ripley in June 2004:

> **Douglas Bates**: There are several chains of pizzerias in the U.S. that provide for Internet-based ordering (e.g. www.papajohnsonline.com) so, with the Internet modules in R, it's only a matter of time before you will have a pizza-ordering function available.

> **Brian D. Ripley**: Indeed, the GraphApp toolkit (used for the RGui interface under R for Windows, but Guido forgot to include it) provides one (for use in Sydney, Australia, we presume as that is where the GraphApp author hails from). Alternatively, a Padovian has no need of ordering pizzas with both home and neighbourhood restaurants ....
> **Brian D. Ripley**: Indeed, the GraphApp toolkit (used for the RGui interface under R for Windows, but Guido forgot to include it) provides one (for use in Sydney, Australia, we presume as that is where the GraphApp author hails from). Alternatively, a Padovian has no need of ordering pizzas with both home and neighborhood restaurants ....

At this point in time, I think it would be fairly straightforward to
build a pizza ordering R package using something like the `RCurl` or
Expand Down
2 changes: 1 addition & 1 deletion manuscript/overview.md
Original file line number Diff line number Diff line change
Expand Up @@ -281,7 +281,7 @@ with Douglas Bates and Brian Ripley in June 2004:

> **Douglas Bates**: There are several chains of pizzerias in the U.S. that provide for Internet-based ordering (e.g. www.papajohnsonline.com) so, with the Internet modules in R, it's only a matter of time before you will have a pizza-ordering function available.

> **Brian D. Ripley**: Indeed, the GraphApp toolkit (used for the RGui interface under R for Windows, but Guido forgot to include it) provides one (for use in Sydney, Australia, we presume as that is where the GraphApp author hails from). Alternatively, a Padovian has no need of ordering pizzas with both home and neighbourhood restaurants ....
> **Brian D. Ripley**: Indeed, the GraphApp toolkit (used for the RGui interface under R for Windows, but Guido forgot to include it) provides one (for use in Sydney, Australia, we presume as that is where the GraphApp author hails from). Alternatively, a Padovian has no need of ordering pizzas with both home and neighborhood restaurants ....

At this point in time, I think it would be fairly straightforward to
build a pizza ordering R package using something like the `RCurl` or
Expand Down
Loading