New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Make an all-NA variable logical #662
Comments
This behavior was defined in 1f352e5, the rational seems to be that if the first X values are missing readr will guess a charcter vector, so if there are non-missing values later they won't be lost, if we guess logical than non missing or T/F vales are lost. |
Yes, this sounds familiar now. Is it prohibitive to do a check after the data has been read to detect all- |
I have a new example of why logical I want to do this: You can see the problem with reprex::reprex_info()
#> Created by the reprex package v0.1.1.9000 on 2017-10-28
library(tidyverse)
df1 <- read_csv("x,y\n1,\n")
df2 <- read_csv("x,y\n3,4\n")
bind_rows(df1, df2)
#> Error in bind_rows_(x, .id): Column `y` can't be converted from character to integer
rbind(df1, df2) ## "works" but is wrong because now y is character
#> # A tibble: 2 x 2
#> x y
#> <int> <chr>
#> 1 1 <NA>
#> 2 3 4
df1 <- read.csv(text = "x,y\n1,\n")
df2 <- read.csv(text = "x,y\n3,4\n")
rbind(df1, df2) %>% as_tibble()
#> # A tibble: 2 x 2
#> x y
#> <int> <int>
#> 1 1 NA
#> 2 3 4
bind_rows(df1, df2) %>% as_tibble()
#> # A tibble: 2 x 2
#> x y
#> <int> <int>
#> 1 1 NA
#> 2 3 4 |
This old issue has been automatically locked. If you believe you have found a related problem, please file a new issue (with reprex) and link to this issue. https://reprex.tidyverse.org/ |
It seems like a variable that is filled with
NA
should be logical not character.I feel like I've raised this issue before and learned that the choice of character was somewhat deliberate? But now I can't remember why. Recent tidyverse ingest discussion supports a default to logical.
Was thinking of this because googlesheets runs data through
readr::read_csv()
in some cases. Working to get consistent result from googlesheets, readxl, and readr for the same data.The text was updated successfully, but these errors were encountered: