Title: Create a Data Dictionary
Version: 1.0.1
Description: Creates a data dictionary from any dataframe or tibble in your R environment. You can opt to add variable labels. You can write the object directly to Excel.
License: MIT + file LICENSE
Encoding: UTF-8
Language: en-GB
RoxygenNote: 7.3.2
Imports: chron, dplyr, haven, labelled, lubridate, openxlsx, stats, tibble, tidyr, tidyselect,
Suggests: covr, testthat (≥ 3.0.0)
Depends: R (≥ 4.1.0)
Config/testthat/edition: 3
URL: https://github.com/DoctorBJones/datadictionary
BugReports: https://github.com/DoctorBJones/datadictionary/issues
NeedsCompilation: no
Packaged: 2025-03-20 22:55:54 UTC; bj
Author: Bethany Jones [aut, cre]
Maintainer: Bethany Jones <r.data.nerd@gmail.com>
Repository: CRAN
Date/Publication: 2025-03-20 23:10:02 UTC

Create a data dictionary from any dataset

Description

Create a data dictionary from any dataset

Usage

create_dictionary(dataset, id_var = NULL, file = NULL, var_labels = NULL)

Arguments

dataset

The dataset you wish to summarise

id_var

A variable/vector of variables that are identifiers (optional)

file

The file path to write an Excel spreadsheet (optional)

var_labels

A named vector of variable labels (optional)

Value

Either an Excel spreadsheet or a dataframe

Examples


 # A simple dictionary printed to console
 create_dictionary(esoph)

 # You can specify id variable/s
 mtcars$id <- 1:nrow(mtcars)
 create_dictionary(mtcars, id_var = "id")

 # You can also specify labels with a named vector
 iris.labels <- c(Sepal.Length = "Sepal length in mm",
     Sepal.Width = "Sepal width in mm",
     Petal.Length = "Petal length in mm",
     Petal.Width = "Petal width in mm",
     Species = "Species of iris")
 create_dictionary(iris, var_labels = iris.labels)


Get the mode of a vector

Description

Get the mode of a vector

Usage

mode_stat(x, freq = FALSE)

Arguments

x

A vector

freq

Boolean when TRUE returns the frequency of the mode


Summarise a single variable

Description

Summarise a single variable

Usage

summarise_variable(dataset, column)

Arguments

dataset

The dataset with the variable you wish to summarise

column

The column you wish to summarise as a quoted string

Value

A dataframe with a summary of the variable

Examples

 summarise_variable(mtcars, "mpg")

 summarise_variable(iris, "Species")