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

Add condense option to print.col_spec #468

Merged
merged 10 commits into from
Jul 13, 2016

Conversation

jimhester
Copy link
Collaborator

@jimhester jimhester commented Jul 11, 2016

Not sure if we want to export condense_spec(), I could see it being useful though, so we may.

Fixes #466

out <- col_spec_standardise("a,b,c,d\n1,2,3,4")
expect_output(print(out, condense = TRUE),
regex_escape(
"cols(.default = col_integer()
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it might be easier to consistently put each argument on its own line

@hadley
Copy link
Member

hadley commented Jul 11, 2016

I agree that it's probably useful enough to export

#' @export
#' @examples
#' df <- read_csv(system.file("mtcars.csv", package = "readr"))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you please use the new readr_example()?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure thing, my system.file call was wrong anyway ;)

@jimhester
Copy link
Collaborator Author

  • The echo'd specs are now condensed by default when the columns are greater than n (default 20).
  • The default argument is on the next line like all other arguments
  • Uses readr_example()
  • condense_spec() is exported, documented along with spec(). (do we like the name?)

}

#' @export
format.col_spec <- function(x, n = Inf, condense = FALSE, ...) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure about this logic. Maybe it should be condense = NULL, then condense <- condense %||% length(x$cols) > n ?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh but that would make the logic below more complicated

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok that works for me

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think your suggestion is better, previously there was no way to explicitly force the output to be condensed (other than calling condense_spec()) directly.

@hadley
Copy link
Member

hadley commented Jul 11, 2016

LGTM - I'm fine with condense_spec() as a name (although maybe it should be spec_condense?

@hadley
Copy link
Member

hadley commented Jul 13, 2016

LGTM

@jimhester jimhester force-pushed the feature/condense-print.col_spec branch from 6543267 to e3ed26c Compare July 13, 2016 14:23
@jimhester jimhester merged commit b0591b9 into tidyverse:master Jul 13, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants