read_glimpse and read.glimpse read the data printed by tibble::glimpse() back into a data frame.

read_glimpse(
  file = clipr::read_clip(),
  class = c("tbl_df", "tbl", "data.frame")
)

read.glimpse(file = clipr::read_clip(), class = "data.frame")

Arguments

file

Character. A path to a file, a connection, or literal data (either a single string or a vector of lines). If unspecified, reads from the clipboard.

class

A character vector of classes to assign to the results.

Value

A data frame of the class specified by the class parameter.

Details

read_glimpse and read.glimpse are roughly inverses of tibble::glimpse, except:

  • they subset to rows where the input contains the complete data for the observation,

  • list and matrix columns are unsupported and may lead to unexpected behavior, and

  • since glimpse does not provide attributes or data frame classes,

    • attributes are dropped, and

    • class is assigned as supplied when called, defaulting to a tibble for read_glimpse and a data.frame for read.glimpse.

Examples

x <- capture.output(tibble::glimpse(iris)) read_glimpse(x)
#> # A tibble: 7 x 5 #> Sepal.Length Sepal.Width Petal.Length Petal.Width Species #> * <dbl> <dbl> <dbl> <dbl> <fct> #> 1 5.1 3.5 1.4 0.2 setosa #> 2 4.9 3 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 3.6 1.4 0.2 setosa #> 6 5.4 3.9 1.7 0.4 setosa #> 7 4.6 3.4 1.4 0.3 setosa
read.glimpse(x)
#> Sepal.Length Sepal.Width Petal.Length Petal.Width Species #> 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 #> 7 4.6 3.4 1.4 0.3 setosa