create_codebook: Create a PDF codebook

Description Usage Arguments

View source: R/create_codebook.R

Description

This function generates LaTeX code (a .tex file) for a nicely-formatted PDF codebook. You need to provide a data frame with a description of each dataset and a data frame with a description of each variable. Once you've generated the .tex file, you can compile the PDF using any LaTeX editor. You need to compile the .tex file using XeLaTeX instead of LaTeX. You will need to compile the PDF twice. You need to have the roboto font installed, which you can download for free on Google Fonts (https://fonts.google.com/specimen/Roboto). You can further customize the .tex file that is generated. Please report bugs and request features at https://github.com/jfjelstul/codebookr/issues.

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
create_codebook(
  file_path,
  datasets_input,
  variables_input,
  title_text,
  version_text,
  footer_text,
  author_names,
  table_of_contents = TRUE,
  include_variable_type = FALSE,
  theme_color = "#3B86F7",
  title_font_size = 16,
  heading_font_size = 35,
  subheading_font_size = 12
)

Arguments

file_path

The path and file for the .tex file that will be created. You need to include the .tex extension in the file name.

datasets_input

A data frame containing information on each dataset. This data frame must include: (1) a variable called dataset that is the name of each dataset, which will be used as the heading for each dataset section; (2) a variable called label that is a short label for each dataset (one line), which will be used as the subheading for each dataset section; and (3) a variable called description that is a description of each dataset, which will be included before the description of each variable. Text wrapped in braces will be formatted as code. The dataset names should be valid R object names.

variables_input

A data frame containing infromation on each variable. This data frame must include: (1) a variable called dataset, where each dataset maps exactly to the datasets in the dataset variable in the datasets_input data frame; and (2) a variable called description that is a description of each variable. Text wrapped in braces will be formatted as code. Optionally, the data frame can include a variable called type that indicates the type of each variable (e.g., numeric, string, etc.). If this variable is included, and the include_variable_type argument is set to TRUE, then the variable type will be included at the beginning of each variable description.

title_text

A string containing the title for the title page.

version_text

A string containing the version number for the title page (e.g., 1.0).

author_names

A string vector containing the names of the authors for the title page or a string if there is one author.

table_of_contents

A logical value indicating whether to include a table of contents.

include_variable_type

A logical value indicating whether to include the type of the variable in the variable description. The variables_input data frame must have a variable called type or you will get an error.

theme_color

A string indicating the color to use. The color should be a valid hex code, including a leading #. If you don't provide a valid hex code, your LaTeX compiler will produce an error (but this function will not).

title_font_size

The size of the font for the title on the title page. You should adjust the font size to make sure your text fits.

heading_font_size

The size of the font for the heading for each dataset section (i.e., the name of the dataset, contained in the dataset variable in the datasets_input data frame). You should adjust the font size to make sure your text fits.

subheading_font_size

The size of the font for the subheading for each dataset section (i.e., the short label for the dataset, contained in the label variable in the datasets_input data frame). You should adjust the font size to make sure your text fits.


jfjelstul/codebookr documentation built on Dec. 20, 2021, 11:07 p.m.