The tibble
S3 generic function pillar::glimpse()
is implemented for
prt
objects as well. Inspired by the output of str()
when applied to
data.frames
, this function is intended to display the structure of the
data in terms of columns, irrespective of how the data is organized in terms
of R
objects. Similarly to format_dt()
, the function providing the bulk
of functionality, glimpse_dt()
, is exported such that implementing a
class specific pillar::glimpse()
function for other classes that
representing tabular data is straightforward.
# S3 method for prt
glimpse(x, width = NULL, ...)glimpse_dt(x, width = NULL)
str_sum(x)
# S3 method for prt
str(object, ...)
str_dt(x, ...)
An object to glimpse at.
Width of output: defaults to the setting of the
width
option (if finite)
or the width of the console.
Unused, for extensibility.
any R object about which you want to have some information.
Alongside a prt
-specific pillar::glimpse()
method, a str()
method is
provided as well for prt
objects. However, breaking with base R
expectations, it is not the structure of the object in terms of R
objects
that is shown, but in the same spirit as pillar::glimpse()
it is the
structure of the data that is printed. How this data is represents with
respect to R
objects is abstracted away as to show output as would be
expected if the data were represented by a data.frame
.
In similar spirit as format_dt()
and glimpse_dt()
, a str_dt()
function
is exported which provides the core functionality driving the prt
implementation of str()
. This function requires availability of a
head()
function for any object that is passed and output can be
customized by implementing an optional str_sum()
function.
cars <- as_prt(mtcars)
pillar::glimpse(cars)
pillar::glimpse(cars, width = 30)
str(cars)
str(cars, vec.len = 1)
str(unclass(cars))
str_sum(cars)
Run the code above in your browser using DataLab