Fixed text to correspond with code output (#784)

My guess is that the guess_parser() function was changed/updated since the writing of this book. From '?guess_parser', the following default is used: 'guess_integer = FALSE'. Thus column 'x' is not problematic anymore.
This commit is contained in:
Bianca Peterson 2020-01-15 20:31:10 +02:00 committed by Hadley Wickham
parent 602baae78c
commit 2712ba113f
1 changed files with 14 additions and 28 deletions

View File

@ -472,39 +472,25 @@ There are two printed outputs: the column specification generated by looking at
problems(challenge)
```
A good strategy is to work column by column until there are no problems remaining. Here we can see that there are a lot of parsing problems with the `x` column - there are trailing characters after the integer value. That suggests we need to use a double parser instead.
To fix the call, start by copying and pasting the column specification into your original call:
```{r, eval = FALSE}
challenge <- read_csv(
readr_example("challenge.csv"),
col_types = cols(
x = col_integer(),
y = col_character()
)
)
```
Then you can tweak the type of the `x` column:
```{r}
challenge <- read_csv(
readr_example("challenge.csv"),
col_types = cols(
x = col_double(),
y = col_character()
)
)
```
That fixes the first problem, but if we look at the last few rows, you'll see that they're dates stored in a character vector:
A good strategy is to work column by column until there are no problems remaining. Here we can see that there are a lot of parsing problems with the `y` column. If we look at the last few rows, you'll see that they're dates stored in a character vector:
```{r}
tail(challenge)
```
You can fix that by specifying that `y` is a date column:
That suggests we need to use a date parser instead. To fix the call, start by copying and pasting the column specification into your original call:
```{r, eval = FALSE}
challenge <- read_csv(
readr_example("challenge.csv"),
col_types = cols(
x = col_double(),
y = col_logical()
)
)
```
Then you can fix the type of the `y` column by specifying that `y` is a date column:
```{r}
challenge <- read_csv(