commit
1ee4e5cc24
|
@ -375,7 +375,7 @@ I mention while loops briefly, because I hardly ever use them. They're most ofte
|
|||
}
|
||||
```
|
||||
|
||||
## For loops vs functionals
|
||||
## For loops vs. functionals
|
||||
|
||||
For loops are not as important in R as they are in other languages because R is a functional programming language. This means that it's possible to wrap up for loops in a function, and call that function instead of using the for loop directly.
|
||||
|
||||
|
|
|
@ -815,7 +815,7 @@ There are a few other functions in base R that accept regular expressions:
|
|||
|
||||
stringr is built on top of the __stringi__ package. stringr is useful when you're learning because it exposes a minimal set of functions, that have been carefully picked to handle the most common string manipulation functions. stringi on the other hand is designed to be comprehensive. It contains almost every function you might ever need. stringi has `r length(ls(getNamespace("stringi")))` functions to stringr's `r length(ls("package:stringr"))`.
|
||||
|
||||
So if you find yourself struggling to do something that doesn't seem natural in stringr, it's worth taking a look at stringi. The use of the two packages is very similar because stringr was designed to mimic stringi's interface. The main difference is the prefix: `str_` vs `stri_`.
|
||||
So if you find yourself struggling to do something that doesn't seem natural in stringr, it's worth taking a look at stringi. The use of the two packages is very similar because stringr was designed to mimic stringi's interface. The main difference is the prefix: `str_` vs. `stri_`.
|
||||
|
||||
### Encoding
|
||||
|
||||
|
|
|
@ -681,7 +681,7 @@ ggplot(delays, aes(n, delay)) +
|
|||
geom_point()
|
||||
```
|
||||
|
||||
Not suprisingly, there is much more variation in the average delay when there are few flights. The shape of this plot is very characteristic: whenever you plot a mean (or many other summaries) vs number of observations, you'll see that the variation decreases as the sample size increases.
|
||||
Not suprisingly, there is much more variation in the average delay when there are few flights. The shape of this plot is very characteristic: whenever you plot a mean (or many other summaries) vs. number of observations, you'll see that the variation decreases as the sample size increases.
|
||||
|
||||
When looking at this sort of plot, it's often useful to filter out the groups with the smallest numbers of observations, so you can see more of the pattern and less of the extreme variation in the smallest groups. This is what the following code does, and also shows you a handy pattern for integrating ggplot2 into dplyr flows. It's a bit painful that you have to switch from `%>%` to `+`, but once you get the hang of it, it's quite convenient.
|
||||
|
||||
|
|
|
@ -38,7 +38,7 @@ frame_data(
|
|||
)
|
||||
```
|
||||
|
||||
## Tibbles vs data frames
|
||||
## Tibbles vs. data frames
|
||||
|
||||
There are two main differences in the usage of a data frame vs a tibble: printing, and subsetting.
|
||||
|
||||
|
|
Loading…
Reference in New Issue