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 number of rows if all rows printed #21

Closed
hadley opened this issue Jan 8, 2016 · 8 comments · Fixed by #51
Closed

Don't print number of rows if all rows printed #21

hadley opened this issue Jan 8, 2016 · 8 comments · Fixed by #51
Milestone

Comments

@hadley
Copy link
Member

hadley commented Jan 8, 2016

e.g.

> data_frame(x = 1:4)
Source: local data frame [4 x 1]

      x
  (int)
1     1
2     2
3     3
4     4

would be better as

> data_frame(x = 1:4)
      x
  (int)
1     1
2     2
3     3
4     4

This normally doesn't matter, but it's useful for books where space is at a premium

@krlmlr
Copy link
Member

krlmlr commented Jan 8, 2016

I'd rather not add special handling here. You can always do data_frame(x = 1:4) %>% trunc_mat or override knit_print.data_frame if space matters. I feel that consistent output can help reducing cognitive load.

@krlmlr
Copy link
Member

krlmlr commented Jan 8, 2016

...but perhaps we can support this with an optional argument save_space = FALSE?

@hadley
Copy link
Member Author

hadley commented Jan 8, 2016

This is important for me. I don't think it's necessary to print a summary of an object when you can see the whole thing.

@krlmlr
Copy link
Member

krlmlr commented Jan 8, 2016

What about the information "Source: local data frame"? I don't see how it becomes less relevant just because the result is small.

May I suggest an alternative printing mode that omits the "Source: ..." information altogether, and adds the remaining number of rows only in case of vertical overflow:

> iris %>% tibble::tbl_df %>% print(n = 6, save_space = TRUE)
   Sepal.Length Sepal.Width Petal.Length Petal.Width Species
          (dbl)       (dbl)        (dbl)       (dbl)  (fctr)
1           5.1         3.5          1.4         0.2  setosa
2           4.9         3.0          1.4         0.2  setosa
3           4.7         3.2          1.3         0.2  setosa
4           4.6         3.1          1.5         0.2  setosa
5           5.0         3.6          1.4         0.2  setosa
6           5.4         3.9          1.7         0.4  setosa
   ... (144 more rows)

> iris %>% tibble::tbl_df %>% head %>% print(n = 6, save_space = TRUE)
   Sepal.Length Sepal.Width Petal.Length Petal.Width Species
          (dbl)       (dbl)        (dbl)       (dbl)  (fctr)
1           5.1         3.5          1.4         0.2  setosa
2           4.9         3.0          1.4         0.2  setosa
3           4.7         3.2          1.3         0.2  setosa
4           4.6         3.1          1.5         0.2  setosa
5           5.0         3.6          1.4         0.2  setosa
6           5.4         3.9          1.7         0.4  setosa

This would be both concise and consistent.

@hadley
Copy link
Member Author

hadley commented Jan 8, 2016

I don't like it as an extra parameter because I don't think anyone will use it. Maybe if it was also a global option.

@krlmlr
Copy link
Member

krlmlr commented Jan 8, 2016

I like the option idea, we might add different printing styles later.

@krlmlr krlmlr modified the milestone: 1.0 Jan 25, 2016
@krlmlr
Copy link
Member

krlmlr commented Jan 26, 2016

New option tibble.show.source.

@krlmlr krlmlr modified the milestones: 1.0, 2.0 Mar 2, 2016
@krlmlr krlmlr removed the question label Mar 2, 2016
@github-actions
Copy link
Contributor

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 15, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants