simple_codebook: Simple Codebook

View source: R/variable_label.R

simple_codebookR Documentation

Simple Codebook

Description

Generate a simple codebook in CSV-format from a (labelled) data.frame.

Usage

simple_codebook(x, ...)

Arguments

x

data.frame. Data to be documented.

...

Arguments passed on to utils::write.table

file

either a character string naming a file or a connection open for writing. "" indicates output to the console.

append

logical. Only relevant if file is a character string. If TRUE, the output is appended to the file. If FALSE, any existing file of the name is destroyed.

quote

a logical value (TRUE or FALSE) or a numeric vector. If TRUE, any character or factor columns will be surrounded by double quotes. If a numeric vector, its elements are taken as the indices of columns to quote. In both cases, row and column names are quoted if they are written. If FALSE, nothing is quoted.

sep

the field separator string. Values within each row of x are separated by this string.

eol

the character(s) to print at the end of each line (row). For example, eol = "\r\n" will produce Windows' line endings on a Unix-alike OS, and eol = "\r" will produce files as expected by Excel:mac 2004.

na

the string to use for missing values in the data.

dec

the string to use for decimal points in numeric or complex columns: must be a single character.

row.names

either a logical value indicating whether the row names of x are to be written along with x, or a character vector of row names to be written.

col.names

either a logical value indicating whether the column names of x are to be written along with x, or a character vector of column names to be written. See the section on ‘CSV files’ for the meaning of col.names = NA.

qmethod

a character string specifying how to deal with embedded double quote characters when quoting strings. Must be one of "escape" (default for write.table), in which case the quote character is escaped in C style by a backslash, or "double" (default for write.csv and write.csv2), in which case it is doubled. You can specify just the initial letter.

fileEncoding

character string: if non-empty declares the encoding to be used on a file (not a connection) so the character data can be re-encoded as they are written. See file.

Details

If the skimr package is installed, an in-line histogram is added for all numeric variables. If columns are labelled, the labelles are included in the codebook.

Value

Returns NULL invisibly.

See Also

utils::write.csv()

Examples

variable_labels(cars) <- c(speed = "Speed [ft/s]", dist = "Distance traveled [m]")
simple_codebook(cars, file = file.path(tempdir(), "cars_codebook.csv"))

papaja documentation built on Oct. 30, 2024, 9:09 a.m.