| 1 |
% Generated by roxygen2: do not edit by hand |
| 2 |
% Please edit documentation in R/type-sum.R |
| 3 |
\name{type_sum} |
| 4 |
\alias{type_sum} |
| 5 |
\alias{obj_sum} |
| 6 |
\alias{size_sum} |
| 7 |
\title{Provide a succinct summary of an object} |
| 8 |
\usage{ |
| 9 |
type_sum(x) |
| 10 |
|
| 11 |
obj_sum(x) |
| 12 |
|
| 13 |
size_sum(x) |
| 14 |
} |
| 15 |
\arguments{ |
| 16 |
\item{x}{an object to summarise. Generally only methods of atomic vectors |
| 17 |
and variants have been implemented.} |
| 18 |
} |
| 19 |
\description{ |
| 20 |
\code{type_sum()} gives a brief summary of object type. Objects that commonly |
| 21 |
occur in a data frame should return a string with four or less characters. |
| 22 |
For most inputs, the argument is forwarded to \code{\link[vctrs:vec_ptype_full]{vctrs::vec_ptype_abbr()}}. |
| 23 |
|
| 24 |
\code{obj_sum()} also includes the size (but not the shape) of the object |
| 25 |
if \code{\link[vctrs:vec_assert]{vctrs::vec_is()}} is \code{TRUE}. |
| 26 |
It should always return a string (a character vector of length one). |
| 27 |
As of pillar v1.6.1, the default method forwards to \code{\link[vctrs:vec_ptype_full]{vctrs::vec_ptype_abbr()}} |
| 28 |
for vectors and to \code{\link[=type_sum]{type_sum()}} for other objects. |
| 29 |
Previous versions always forwarded to \code{\link[=type_sum]{type_sum()}}. |
| 30 |
An attribute named \code{"short"} in the return value will be picked up by |
| 31 |
the \code{\link[=pillar_shaft]{pillar_shaft()}} method for lists, and used if space is limited. |
| 32 |
|
| 33 |
\code{size_sum()} is called by \code{obj_sum()} to format the size of the object. |
| 34 |
It should always return a string (a character vector of length one), |
| 35 |
it can be an empty string \code{""} to omit size information, |
| 36 |
this is what the default method does for scalars. |
| 37 |
} |
| 38 |
\details{ |
| 39 |
When formatting a pillar, |
| 40 |
\code{type_sum()} will be called on a slice of the column vector. |
| 41 |
The formatted type should only depend on the type and not on the data, |
| 42 |
to avoid confusion. |
| 43 |
} |
| 44 |
\examples{ |
| 45 |
obj_sum(1:10) |
| 46 |
obj_sum(matrix(1:10)) |
| 47 |
obj_sum(data.frame(a = 1)) |
| 48 |
obj_sum(Sys.Date()) |
| 49 |
obj_sum(Sys.time()) |
| 50 |
obj_sum(mean) |
| 51 |
|
| 52 |
size_sum(1:10) |
| 53 |
size_sum(trees) |
| 54 |
size_sum(Titanic) |
| 55 |
} |
| 56 |
\keyword{internal} |