Merge pull request #8 from Robinlovelace/master

Minor fixes to string manipulation chapter
This commit is contained in:
Hadley Wickham 2015-11-09 06:30:45 -06:00
commit d963d3415f
1 changed files with 3 additions and 3 deletions

View File

@ -57,17 +57,17 @@ x
Base R contains many functions to work with strings but we'll generally avoid them because they're inconsistent and hard to remember. Their behaviour is particularly inconsistent when it comes to missing values. For examle, `nchar()`, which gives the length of a string, returns 2 for `NA` (instead of `NA`)
```{r}
# (Will be fixed in R 3.3.0)
# Bug will be fixed in R 3.3.0
nchar(NA)
```
Instead we'll use functions from stringr. These have more evocative names, and all start with `str_`:
Instead we'll use functions from stringr. These have more intuitive names, and all start with `str_`:
```{r}
str_length(NA)
```
The common `str_` prefix is particularly useful if you use RStudio, because typing `str_` trigger autocomplete, so you can easily see all of the stringr functions.
The common `str_` prefix is particularly useful if you use RStudio, because typing `str_` will trigger autocomplete, allowing you to see all stringr functions.
### Combining strings