Merge pull request #8 from Robinlovelace/master
Minor fixes to string manipulation chapter
This commit is contained in:
commit
d963d3415f
|
@ -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
|
||||
|
||||
|
|
Loading…
Reference in New Issue