-
Notifications
You must be signed in to change notification settings - Fork 12
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
Collect first n rows of a record? #182
Comments
We did actually talk about this here #41. dplyr 1.0.0 is actually going to be deprecating @ateucher One thing we could do is use |
I say we do a |
Sorry @ateucher - I wrote |
Oh well that is annoying. What about just a |
Sure. And |
Yup, and when I said in the |
What would the syntax be here? I see three options:
Issue with ☝️ is that collects without
☝️ is just weird
But what about this approach? Can you add arguments to a method? Not set on n as the argument name but maybe we could specify in the final |
|
You can add arguments to a method (as long as the generic has
which is what dbplyr's library(tidyverse)
con <- DBI::dbConnect(RSQLite::SQLite(), ":memory:")
mtcars_db <- copy_to(con, rownames_to_column(mtcars), "mtcars")
head_mtcars_db <- head(mtcars_db)
head_mtcars_db
#> # Source: lazy query [?? x 12]
#> # Database: sqlite 3.30.1 [:memory:]
#> rowname mpg cyl disp hp drat wt qsec vs am gear carb
#> <chr> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl>
#> 1 Mazda RX4 21 6 160 110 3.9 2.62 16.5 0 1 4 4
#> 2 Mazda RX4 W… 21 6 160 110 3.9 2.88 17.0 0 1 4 4
#> 3 Datsun 710 22.8 4 108 93 3.85 2.32 18.6 1 1 4 1
#> 4 Hornet 4 Dr… 21.4 6 258 110 3.08 3.22 19.4 1 0 3 1
#> 5 Hornet Spor… 18.7 8 360 175 3.15 3.44 17.0 0 0 3 2
#> 6 Valiant 18.1 6 225 105 2.76 3.46 20.2 1 0 3 1
class(head_mtcars_db)
#> [1] "tbl_SQLiteConnection" "tbl_dbi" "tbl_sql"
#> [4] "tbl_lazy" "tbl"
collect(head_mtcars_db)
#> # A tibble: 6 x 12
#> rowname mpg cyl disp hp drat wt qsec vs am gear carb
#> <chr> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl>
#> 1 Mazda RX4 21 6 160 110 3.9 2.62 16.5 0 1 4 4
#> 2 Mazda RX4 W… 21 6 160 110 3.9 2.88 17.0 0 1 4 4
#> 3 Datsun 710 22.8 4 108 93 3.85 2.32 18.6 1 1 4 1
#> 4 Hornet 4 Dr… 21.4 6 258 110 3.08 3.22 19.4 1 0 3 1
#> 5 Hornet Spor… 18.7 8 360 175 3.15 3.44 17.0 0 0 3 2
#> 6 Valiant 18.1 6 225 105 2.76 3.46 20.2 1 0 3 1 Created on 2020-04-17 by the reprex package (v0.3.0) |
I am not sure I think
is actually weird— feels like it is consistent with the design wrt to |
I agree, I think it's the right way |
I do see how this is how dbplyr implements this. I, do, however think that there could be some discussion on whether this is right. By calling
|
So we've basically landed on supporting both this:
and this:
|
1 similar comment
So we've basically landed on supporting both this:
and this:
|
So |
So we've basically landed on supporting both this:
and this:
Am I right there? |
That is where we landed but I wonder if we're just fence-sitting? It still seems strange to me that |
OK, final decision: Mimic |
And for posterity the reason for this is because |
Hi - when using bcdc_query_geodata %>% collect(), is it possible to somehow collect just the first n rows of the record? This would be extremely helpful to take a quick look at the data, see how its structured, see what type of values are in there, etc... The current code returns the top 6 lines in the browser, which is really useful, however, collecting the first ~500 records would be really handy!
Something like:
bcdc_query_geodata("results-forest-cover-silviculture") %>%
collect(top_n(500))
The text was updated successfully, but these errors were encountered: