Skip to content

Commit

Permalink
Merge pull request hadley#8 from Robinlovelace/master
Browse files Browse the repository at this point in the history
Minor fixes to string manipulation chapter
  • Loading branch information
hadley committed Nov 9, 2015
2 parents 34d62f5 + 7e8d4fa commit d963d34
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions strings.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down

0 comments on commit d963d34

Please sign in to comment.