You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When I use a connection to a sqlite on disk, the verb n_distinct() returns an error if there are two or more columns. Same code, if I select just one column or collect data before counting record, it works properly.
# remove objects
rm(list= ls())
# require packages
require(dplyr)
require(dbplyr)
require(RSQLite)
# create a sqlite db and connect to itcon<-DBI::dbConnect(RSQLite::SQLite(), ":memory:")
# copy data into sqlite
copy_to(con, mtcars)
# point to table my_tbl<- tbl(con, "mtcars")
# n_distinct with one column (THIS WORKS)my_tbl %>% group_by(gear) %>% summarise(n_distinct(mpg))
# if I use the local (or collected) data it is ok (THIS WORKS)my_tbl %>% collect() %>% group_by(gear) %>% summarise(n_distinct(mpg, cyl))
# n_distinct with two columns (THIS DOES NOT WORKS)my_tbl %>% group_by(gear) %>% summarise(n_distinct(mpg, cyl))
## Error in result_create(conn@ptr, statement) : ## wrong number of arguments to function COUNT()
The code is correctly translated into Sql
# Show querymy_tbl %>% group_by(gear) %>% summarise(n_distinct(mpg, cyl)) %>% show_query()
## SELECT `gear`, COUNT(DISTINCT `mpg`, `cyl`) AS `n_distinct(mpg, cyl)`## FROM `mtcars`## GROUP BY `gear`
The text was updated successfully, but these errors were encountered:
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/
lockbot
locked and limited conversation to collaborators
Dec 17, 2018
This issue was closed.
Sign up for freeto subscribe to this conversation on GitHub.
Already have an account?
Sign in.
When I use a connection to a sqlite on disk, the verb n_distinct() returns an error if there are two or more columns. Same code, if I select just one column or collect data before counting record, it works properly.
The code is correctly translated into Sql
The text was updated successfully, but these errors were encountered: