Skip to contents

Codebook Maker

Usage

make_codebook(
  input_df,
  return_df = TRUE,
  format = NULL,
  escape = TRUE,
  extra_vars = NULL,
  extra_key = NULL,
  ...
)

Arguments

input_df

A data.frame that will be summarized as a codebook.

return_df

A boolean set by default to TRUE, if FALSE it will return the table as HTML or LaTeX.

format

A string set to NULL by default. If NULL and the return_df parameter is set to FALSE, this argument may be set to "html" or "latex" to determine the output of the table.

escape

A boolean; whether to escape special characters when producing HTML or LaTeX tables. When escape = FALSE, you have to make sure that special characters will not trigger syntax errors in LaTeX or HTML.

extra_vars

A data.frame of variables that wil be left joined.

extra_key

A character; specifying the column used for merging the extra_vars table.

...

Other arguments (see Examples and References).

Examples

if (FALSE) {
# Create a test data.frame
test <- data.frame("Incident_Type" = c("WSP", "WMCI", "WHF", "WWC", "WHCC", 
                                        "WSP", "WMCI", "WHF", "WWC", "WHCC"),
 "n" = seq(1, 10),
 "n2" = as.double( seq(11, 20) ),
 "string" = c(LETTERS[1:10]),
 "test2" = c("A", "A", "B", "B", "C", "C", "D", "E", "F", "A"),
 "factor" = as.factor(rep(letters[1:5], 2)),
 "test" = c(rep(TRUE, 6), FALSE, NA, NA, NA)
 )

# Return HTML table.
codemaker(test, return_df =  FALSE, format = "html", 
latex_options = "striped", escape = FALSE, extra_vars = added_vars, 
extra_key = "var_name")

}