File: type_sum.Rd

package info (click to toggle)
r-cran-pillar 1.8.1%2Bdfsg-1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 1,840 kB
  • sloc: sh: 13; makefile: 2
file content (56 lines) | stat: -rw-r--r-- 1,952 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/type-sum.R
\name{type_sum}
\alias{type_sum}
\alias{obj_sum}
\alias{size_sum}
\title{Provide a succinct summary of an object}
\usage{
type_sum(x)

obj_sum(x)

size_sum(x)
}
\arguments{
\item{x}{an object to summarise. Generally only methods of atomic vectors
and variants have been implemented.}
}
\description{
\code{type_sum()} gives a brief summary of object type. Objects that commonly
occur in a data frame should return a string with four or less characters.
For most inputs, the argument is forwarded to \code{\link[vctrs:vec_ptype_full]{vctrs::vec_ptype_abbr()}}.

\code{obj_sum()} also includes the size (but not the shape) of the object
if \code{\link[vctrs:vec_assert]{vctrs::vec_is()}} is \code{TRUE}.
It should always return a string (a character vector of length one).
As of pillar v1.6.1, the default method forwards to \code{\link[vctrs:vec_ptype_full]{vctrs::vec_ptype_abbr()}}
for vectors and to \code{\link[=type_sum]{type_sum()}} for other objects.
Previous versions always forwarded to \code{\link[=type_sum]{type_sum()}}.
An attribute named \code{"short"} in the return value will be picked up by
the \code{\link[=pillar_shaft]{pillar_shaft()}} method for lists, and used if space is limited.

\code{size_sum()} is called by \code{obj_sum()} to format the size of the object.
It should always return a string (a character vector of length one),
it can be an empty string \code{""} to omit size information,
this is what the default method does for scalars.
}
\details{
When formatting a pillar,
\code{type_sum()} will be called on a slice of the column vector.
The formatted type should only depend on the type and not on the data,
to avoid confusion.
}
\examples{
obj_sum(1:10)
obj_sum(matrix(1:10))
obj_sum(data.frame(a = 1))
obj_sum(Sys.Date())
obj_sum(Sys.time())
obj_sum(mean)

size_sum(1:10)
size_sum(trees)
size_sum(Titanic)
}
\keyword{internal}