Dplyr: Implement view

Created on 2 Jan 2018  路  8Comments  路  Source: tidyverse/dplyr

i.e.

view <- function(x) {
  if (interactive()) {
    View(x)
  }
  invisible(x)
}

Advantages over View():

  • Guaranteed to invisibly return x
  • Does nothing when not in an interactive context

Most helpful comment

"Does nothing when not in an interactive context" will be very useful to avoid issues when it's (mistakenly) used in an R Markdown document

All 8 comments

Consider making it a generic

"Does nothing when not in an interactive context" will be very useful to avoid issues when it's (mistakenly) used in an R Markdown document

Echo on making it a generic, that way we can get it to work on tbl_sql objects, where we can collect() the top 1,000 records and have it open a data viewer, unlike the list viewer that it opens today if I don't perform collect() first.

Should this live in tibble?

I'm not sure - on one hand it seems better because tibble is a lower-level package; but on the other tibble, generally doesn't provide generic verbs.

We do have print() and glimpse() in tibble, so view() seems like a good fit.

Well, print() lives in base, but glimpse() is a compelling argument. Let's move this to tibble.

Was this page helpful?
0 / 5 - 0 ratings