Compactly display the content and structure of a data.frame, including variable labels. str() is optimized for lists and its output is relatively technical, when it comes to e.g. attributes. summary() on the other side already calculates some basic statistics.

Abstract(
  x,
  sep = ", ",
  zero.form = ".",
  maxlevels = 5,
  trunc = TRUE,
  list.len = 999
)

# S3 method for class 'abstract'
print(x, sep = NULL, width = NULL, trunc = NULL, print.gap = 2, ...)

Arguments

x

a data.frame to be described

sep

the separator for concatenating the levels of a factor

zero.form

a symbol to be used, when a variable has zero NAs.

maxlevels

(integer, Inf) Max. number of factor levels to display. Default is 5. Set this to Inf, if all levels are needed.

trunc

logical, defining if level names exceeding the column with should be truncated. Default is TRUE.

list.len

numeric; maximum number of list elements to display.

width

Console width. If NULL, defaults to options("width").

print.gap

(integer) Number of spaces between columns.

...

Further arguments to print method.

Value

an object of class abstract, essentially a character matrix with 5 or 6 columns containing:

  1. a column number (Nr),

  2. the name of the column (ColName),

  3. the column class (Class),

  4. the number of NAs (NAs),

  5. the levels if the variable is a factor (Levels),

  6. (if there are any) descriptive labels for the column (Labels).

Details

The levels of a factor and describing variable labels (as created by Label()) will be wrapped within the columns.

The first 4 columns are printed with the needed fix width, the last 2 (Levels and Labels) are wrapped within the column. The width is calculated depending on the width of the screen as given by getOption("width").

ToWord has an interface for the class abstract.

See also

utils::str(), base::summary(), ColumnWrap(), Desc()

Other Statistical summary functions: Desc()

Author

Andri Signorell andri@signorell.net

Examples


d.mydata <- d.pizza
# let's use some labels
Label(d.mydata) <- "Lorem ipsum dolor sit amet, consetetur sadipscing elitr,
sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat,
sed diam voluptua. At vero eos et accusam."

Label(d.mydata$temperature) <- "Amet, consetetur sadipscing elitr, sed diam nonumy "

Abstract(d.mydata)
#> ────────────────────────────────────────────────────────────────────────────── 
#> d.mydata :
#>   Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam
#>   nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam
#>   erat, sed diam voluptua. At vero eos et accusam.
#> 
#> data frame:	1209 obs. of  16 variables
#> 		917 complete cases (75.8%)
#> 
#>   Nr  Class  ColName         NAs          Levels            Label           
#>   1   int    index             .                            -               
#>   2   dat    date             32 (2.6%)                     -               
#>   3   num    week             32 (2.6%)                     -               
#>   4   num    weekday          32 (2.6%)                     -               
#>   5   fac    area             10 (0.8%)   (3): 1-Brent,     -               
#>                                           2-Camden,                         
#>                                           3-Westminster                     
#>   6   int    count            12 (1.0%)                     -               
#>   7   log    rabate           12 (1.0%)                     -               
#>   8   num    price            12 (1.0%)                     -               
#>   9   fac    operator          8 (0.7%)   (3): 1-Allanah,   -               
#>                                           2-Maria,                          
#>                                           3-Rhonda                          
#>   10  fac    driver            5 (0.4%)   (7): 1-Butcher,   -               
#>                                           2-Carpenter,                      
#>                                           3-Carter,                         
#>                                           4-Farmer,                         
#>                                           5-Hunter, ...                     
#>   11  num    delivery_min      .                            -               
#>   12  num    temperature      39 (3.2%)                     Amet, consetetur
#>                                                             sadipscing      
#>                                                             elitr, sed diam 
#>                                                             nonumy          
#>   13  int    wine_ordered     12 (1.0%)                     -               
#>   14  int    wine_delivered   12 (1.0%)                     -               
#>   15  log    wrongpizza        4 (0.3%)                     -               
#>   16  ord    quality         201 (16.6%)  (3): 1-low,       -               
#>                                           2-medium, 3-high                  
#>