Skip to content
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

is.na() produces Error: $ operator is invalid for atomic vectors #1

Open
ablack3 opened this issue Nov 19, 2018 · 1 comment
Open

Comments

@ablack3
Copy link

ablack3 commented Nov 19, 2018

Hi @edgararuiz ,

This branch fixes an important issue for me and allows me to use %in% and case_when with MS SQL server. However it seems to create a new problem when I use is.na.

Any ideas what is causing the problem or how I can work around it?

library(dplyr)
con <- DBI::dbConnect(odbc::odbc(), Driver = "SQL Server", Server = "test_server", Database = "test_db")
mtcars_db <- tbl(con, "mtcars")
mtcars_db %>% 
  mutate(missing_mpg = ifelse(is.na(mpg), "missing", "not missing"))
#> Error: $ operator is invalid for atomic vectors
@ablack3
Copy link
Author

ablack3 commented Nov 19, 2018

Ok I think I found a workaround.

This works...

mtcars_db %>% 
  mutate(tmp = is.na(mpg)*1) %>% 
  mutate(missing_mpg = ifelse(tmp == 1, "missing", "not missing")) %>% 
  select(mpg, missing_mpg)

But this does not.

mtcars_db %>% 
  mutate(tmp = is.na(mpg)) %>% 
  mutate(missing_mpg = ifelse(tmp, "missing", "not missing"))

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant