Skip to content

Commit

Permalink
glimpse now (invisibly) returns x, so glimpse can be used within a ch…
Browse files Browse the repository at this point in the history
…ain of dplyr verbs.
  • Loading branch information
edwindj committed Dec 4, 2015
1 parent 4f2d7f8 commit 05007df
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions R/glimpse.R
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@
#' @param x An object to glimpse at.
#' @param width Width of output: defaults to the width of the console.
#' @param ... Other arguments passed onto individual methods.
#' @return x original x is (invisibly) returned, allowing \code{glimpse} to be
#' used within a data pipe line.
#' @export
#' @examples
#' glimpse(mtcars)
Expand Down Expand Up @@ -49,6 +51,7 @@ glimpse.tbl <- function(x, width = getOption("width"), ...) {
truncated <- str_trunc(formatted, data_width)

cat(paste0(var_names, truncated, collapse = "\n"), "\n", sep = "")
invisible(x)
}

#' @export
Expand All @@ -57,6 +60,7 @@ glimpse.data.frame <- glimpse.tbl
#' @export
glimpse.default <- function(x, width = getOption("width"), max.level = 3, ...) {
str(x, width = width, max.level = max.level, ...)
invisible(x)
}

str_trunc <- function(x, max_width) {
Expand Down

0 comments on commit 05007df

Please sign in to comment.