Debian Codegraph @

man/format_glimpse.Rd

raw
1 % Generated by roxygen2: do not edit by hand
2 % Please edit documentation in R/glimpse.R
3 \name{format_glimpse}
4 \alias{format_glimpse}
5 \title{Format a vector for horizontal printing}
6 \usage{
7 format_glimpse(x, ...)
8 }
9 \arguments{
10 \item{x}{A vector.}
11
12 \item{...}{Arguments passed to methods.}
13 }
14 \value{
15 A character vector of the same length as \code{x}.
16 }
17 \description{
18 \ifelse{html}{\href{https://lifecycle.r-lib.org/articles/stages.html#experimental}{\figure{lifecycle-experimental.svg}{options: alt='[Experimental]'}}}{\strong{[Experimental]}}
19
20 This generic provides the logic for printing vectors in \code{\link[=glimpse]{glimpse()}}.
21
22 The output strives to be as unambiguous as possible,
23 without compromising on readability.
24 In a list, to distinguish between vectors and nested lists,
25 the latter are surrounded by \verb{[]} brackets.
26 Empty lists are shown as \verb{[]}.
27 Vectors inside lists, of length not equal to one,
28 are surrounded by \verb{<>} angle brackets.
29 Empty vectors are shown as \verb{<>}.
30 }
31 \examples{
32 format_glimpse(1:3)
33
34 # Lists use [], vectors inside lists use <>
35 format_glimpse(list(1:3))
36 format_glimpse(list(1, 2:3))
37 format_glimpse(list(list(1), list(2:3)))
38 format_glimpse(list(as.list(1), as.list(2:3)))
39 format_glimpse(list(character()))
40 format_glimpse(list(NULL))
41
42 # Character strings are always quoted
43 writeLines(format_glimpse(letters[1:3]))
44 writeLines(format_glimpse(c("A", "B, C")))
45
46 # Factors are quoted only when needed
47 writeLines(format_glimpse(factor(letters[1:3])))
48 writeLines(format_glimpse(factor(c("A", "B, C"))))
49 }