From 2712ba113f9e4bef5fc7bb5766ad22801a9071f1 Mon Sep 17 00:00:00 2001 From: Bianca Peterson Date: Wed, 15 Jan 2020 20:31:10 +0200 Subject: [PATCH] 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. --- import.Rmd | 42 ++++++++++++++---------------------------- 1 file changed, 14 insertions(+), 28 deletions(-) diff --git a/import.Rmd b/import.Rmd index dcd9ad9..d2e7c8c 100644 --- a/import.Rmd +++ b/import.Rmd @@ -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(