Skip to contents

[Stable]

The codebook function generates a codebook for the given dataset. It provides a summary of the dataset's structure and characteristics, including variable names, types, missing values, completeness percentages, unique value counts, and variable labels (if available).

Usage

codebook(data)

Arguments

data

The dataset for which the codebook is to be generated.

Value

The input dataset is returned invisibly, allowing codebook() to be used within a data pipe line.

See also

Other Data Management: append(), count_functions, cut(), tag_duplicates()

Examples

codebook(mtcars)
#> $ Codebook
#>   dataset: mtcars
#>   Row: 32
#>   Col: 11
#>    name type  miss complete unique label
#> 1  mpg  <dbl> 0    1.00     25          
#> 2  cyl  <dbl> 0    1.00      3          
#> 3  disp <dbl> 0    1.00     27          
#> 4  hp   <dbl> 0    1.00     22          
#> 5  drat <dbl> 0    1.00     22          
#> 6  wt   <dbl> 0    1.00     29          
#> 7  qsec <dbl> 0    1.00     30          
#> 8  vs   <dbl> 0    1.00      2          
#> 9  am   <dbl> 0    1.00      2          
#> 10 gear <dbl> 0    1.00      3          
#> 11 carb <dbl> 0    1.00      6          

codebook(iris)
#> $ Codebook
#>   dataset: iris
#>   Row: 150
#>   Col: 5
#>   name         type  miss complete unique label
#> 1 Sepal.Length <dbl> 0    1.00     35          
#> 2 Sepal.Width  <dbl> 0    1.00     23          
#> 3 Petal.Length <dbl> 0    1.00     43          
#> 4 Petal.Width  <dbl> 0    1.00     22          
#> 5 Species      <fct> 0    1.00      3          

labelled::var_label(iris) <- c(
  "sepal length", "sepal width", "petal length",
  "petal width", "species"
)
codebook(iris)
#> $ Codebook
#>   dataset: iris
#>   Row: 150
#>   Col: 5
#>   name         type  miss complete unique label       
#> 1 Sepal.Length <dbl> 0    1.00     35     sepal length
#> 2 Sepal.Width  <dbl> 0    1.00     23     sepal width 
#> 3 Petal.Length <dbl> 0    1.00     43     petal length
#> 4 Petal.Width  <dbl> 0    1.00     22     petal width 
#> 5 Species      <fct> 0    1.00      3     species