1

I'm not able to count missing values using dbplyr on a posgresql database. I have 350 columns and i'd like to use something like that (that works on local)

db = tbl(con, 'db')

db %>%
summarise_all(
    function(x) sum(is.na(x))
)

but I get

Error in (function (x)  : object "market" not found

where 'market' is a variable in the db

Is there any shortcut to make this work?

Mr Mart
  • 11
  • 1
  • Please do this https://stackoverflow.com/help/mcve such as this https://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example to help the community help you – Krantz Feb 27 '19 at 13:16
  • Have you viewed the SQL query? Please post the contents of `db %>% summarise_all(function (x) sum(is.na(x)) %>% show_query()`. – Simon.S.A. Mar 28 '19 at 23:25

1 Answers1

0

I had the same problem. I found that casting the cols as an integer solved it. Let df be a lazy table or db connection.

df %>%
    summarise(n_missing = sum(as.integer(is.na(col_you_want)))
Kai Lukowiak
  • 63
  • 1
  • 6