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

Don't print "with more rows" if result set contains exactly 10 rows #371

Closed
krlmlr opened this issue Jan 19, 2018 · 6 comments
Closed

Don't print "with more rows" if result set contains exactly 10 rows #371

krlmlr opened this issue Jan 19, 2018 · 6 comments
Labels
Milestone

Comments

@krlmlr
Copy link
Member

@krlmlr krlmlr commented Jan 19, 2018

dbplyr::memdb_frame(a = 1:10)
#> # Source:   table<wrcfejsauq> [?? x 1]
#> # Database: sqlite 3.19.3 [:memory:]
#>        a
#>    <int>
#>  1     1
#>  2     2
#>  3     3
#>  4     4
#>  5     5
#>  6     6
#>  7     7
#>  8     8
#>  9     9
#> 10    10
#> # ... with more rows

Created on 2018-01-19 by the reprex package (v0.1.1.9000).

We could fetch 21 rows instead of 10, to make sure we're consistent with the behavior for data frames (to display the first 20 rows if the result has 20 rows or less). If we get 20 or less, we display. If we get 21, we display the first 10 and show "with at least 11 more rows".

@krlmlr
Copy link
Member Author

@krlmlr krlmlr commented Jan 21, 2018

Postponing, because output might change results of revdepchecks.

@stefanedwards
Copy link

@stefanedwards stefanedwards commented Jul 4, 2018

Adding on top of this, using print(..., n=-1) we can get all rows printed, but print.tbl still outputs a "... with xx more rows":

Note, mtcars contains 32 rows:

print(as_tibble(mtcars))
# A tibble: 32 x 11
     mpg   cyl  disp    hp  drat    wt  qsec    vs    am  gear  carb
 * <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl>
 1  21.0    6.  160.  110.  3.90  2.62  16.5    0.    1.    4.    4.
 2  21.0    6.  160.  110.  3.90  2.88  17.0    0.    1.    4.    4.
 3  22.8    4.  108.   93.  3.85  2.32  18.6    1.    1.    4.    1.
 4  21.4    6.  258.  110.  3.08  3.22  19.4    1.    0.    3.    1.
 5  18.7    8.  360.  175.  3.15  3.44  17.0    0.    0.    3.    2.
 6  18.1    6.  225.  105.  2.76  3.46  20.2    1.    0.    3.    1.
 7  14.3    8.  360.  245.  3.21  3.57  15.8    0.    0.    3.    4.
 8  24.4    4.  147.   62.  3.69  3.19  20.0    1.    0.    4.    2.
 9  22.8    4.  141.   95.  3.92  3.15  22.9    1.    0.    4.    2.
10  19.2    6.  168.  123.  3.92  3.44  18.3    1.    0.    4.    4.
# ... with 22 more rows

This time, forcing all rows printed:

print(as_tibble(mtcars), n=-1)
# A tibble: 32 x 11
     mpg   cyl  disp    hp  drat    wt  qsec    vs    am  gear  carb
 * <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl>
 1  21.0    6. 160.   110.  3.90  2.62  16.5    0.    1.    4.    4.
 2  21.0    6. 160.   110.  3.90  2.88  17.0    0.    1.    4.    4.
 3  22.8    4. 108.    93.  3.85  2.32  18.6    1.    1.    4.    1.
 4  21.4    6. 258.   110.  3.08  3.22  19.4    1.    0.    3.    1.
 5  18.7    8. 360.   175.  3.15  3.44  17.0    0.    0.    3.    2.
 6  18.1    6. 225.   105.  2.76  3.46  20.2    1.    0.    3.    1.
 7  14.3    8. 360.   245.  3.21  3.57  15.8    0.    0.    3.    4.
 8  24.4    4. 147.    62.  3.69  3.19  20.0    1.    0.    4.    2.
 9  22.8    4. 141.    95.  3.92  3.15  22.9    1.    0.    4.    2.
10  19.2    6. 168.   123.  3.92  3.44  18.3    1.    0.    4.    4.
11  17.8    6. 168.   123.  3.92  3.44  18.9    1.    0.    4.    4.
12  16.4    8. 276.   180.  3.07  4.07  17.4    0.    0.    3.    3.
13  17.3    8. 276.   180.  3.07  3.73  17.6    0.    0.    3.    3.
14  15.2    8. 276.   180.  3.07  3.78  18.0    0.    0.    3.    3.
15  10.4    8. 472.   205.  2.93  5.25  18.0    0.    0.    3.    4.
16  10.4    8. 460.   215.  3.00  5.42  17.8    0.    0.    3.    4.
17  14.7    8. 440.   230.  3.23  5.34  17.4    0.    0.    3.    4.
18  32.4    4.  78.7   66.  4.08  2.20  19.5    1.    1.    4.    1.
19  30.4    4.  75.7   52.  4.93  1.62  18.5    1.    1.    4.    2.
20  33.9    4.  71.1   65.  4.22  1.84  19.9    1.    1.    4.    1.
21  21.5    4. 120.    97.  3.70  2.46  20.0    1.    0.    3.    1.
22  15.5    8. 318.   150.  2.76  3.52  16.9    0.    0.    3.    2.
23  15.2    8. 304.   150.  3.15  3.44  17.3    0.    0.    3.    2.
24  13.3    8. 350.   245.  3.73  3.84  15.4    0.    0.    3.    4.
25  19.2    8. 400.   175.  3.08  3.84  17.0    0.    0.    3.    2.
26  27.3    4.  79.0   66.  4.08  1.94  18.9    1.    1.    4.    1.
27  26.0    4. 120.    91.  4.43  2.14  16.7    0.    1.    5.    2.
28  30.4    4.  95.1  113.  3.77  1.51  16.9    1.    1.    5.    2.
29  15.8    8. 351.   264.  4.22  3.17  14.5    0.    1.    5.    4.
30  19.7    6. 145.   175.  3.62  2.77  15.5    0.    1.    5.    6.
31  15.0    8. 301.   335.  3.54  3.57  14.6    0.    1.    5.    8.
# ... with 33 more rows

I'd say n=-1 works in line with base read.table and such to not have an upper limit. So it makes good sense to keep it like this.

@krlmlr
Copy link
Member Author

@krlmlr krlmlr commented Jul 14, 2018

Unfortunately, n = -1 is just passed to head(), this means that 31 out of 32 rows are printed. Thanks for spotting this problem.

I don't like the idea of supporting -1 as a shortcut for "everything", we can already use n = Inf for this.

@krlmlr krlmlr added bug and removed feature labels Jul 14, 2018
@stefanedwards
Copy link

@stefanedwards stefanedwards commented Jul 16, 2018

Oh no, I'm an idiot who cannot count to 32 (!). I am just used to start counting at 0, so I did not see that n=-1 left the last entry out...

I agree, n = Inf works better and does not in this case print that there are more rows. Fun fact, using n =-31 will print that there are 63 more rows.

I think that's all from me for now.

@krlmlr
Copy link
Member Author

@krlmlr krlmlr commented Jul 21, 2018

Thanks for the heads-up, and again for filing the issue!

@krlmlr krlmlr added this to the 1.5.0 milestone Oct 5, 2018
@krlmlr krlmlr closed this in 3be9fcb Oct 5, 2018
@github-actions
Copy link

@github-actions github-actions bot commented Dec 10, 2020

This old thread has been automatically locked. If you think you have found something related to this, please open a new issue and link to this old issue if necessary.

@github-actions github-actions bot locked and limited conversation to collaborators Dec 10, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
2 participants