View source: R/data_codebook.R
data_codebook | R Documentation |
data_codebook()
generates codebooks from data frames, i.e. overviews
of all variables and some more information about each variable (like
labels, values or value range, frequencies, amount of missing values).
data_codebook(
data,
select = NULL,
exclude = NULL,
variable_label_width = NULL,
value_label_width = NULL,
max_values = 10,
range_at = 6,
ignore_case = FALSE,
regex = FALSE,
verbose = TRUE,
...
)
## S3 method for class 'data_codebook'
print_html(
x,
font_size = "100%",
line_padding = 3,
row_color = "#eeeeee",
...
)
data |
A data frame, or an object that can be coerced to a data frame. |
select |
Variables that will be included when performing the required tasks. Can be either
If |
exclude |
See |
variable_label_width |
Length of variable labels. Longer labels will be
wrapped at |
value_label_width |
Length of value labels. Longer labels will be shortened, where the remaining part is truncated. Only applies to labelled data or factor levels. |
max_values |
Number of maximum values that should be displayed. Can be used to avoid too many rows when variables have lots of unique values. |
range_at |
Indicates how many unique values in a numeric vector are needed in order to print a range for that variable instead of a frequency table for all numeric values. Can be useful if the data contains numeric variables with only a few unique values and where full frequency tables instead of value ranges should be displayed. |
ignore_case |
Logical, if |
regex |
Logical, if |
verbose |
Toggle warnings and messages on or off. |
... |
Arguments passed to or from other methods. |
x |
A (grouped) data frame, a vector or a statistical model (for
|
font_size |
For HTML tables, the font size. |
line_padding |
For HTML tables, the distance (in pixel) between lines. |
row_color |
For HTML tables, the fill color for odd rows. |
A formatted data frame, summarizing the content of the data frame.
Returned columns include the column index of the variables in the original
data frame (ID
), column name, variable label (if data is labelled), type
of variable, number of missing values, unique values (or value range),
value labels (for labelled data), and a frequency table (N for each value).
Most columns are formatted as character vectors.
There are methods to print()
the data frame in a nicer output, as
well methods for printing in markdown or HTML format (print_md()
and
print_html()
).
data(iris)
data_codebook(iris, select = starts_with("Sepal"))
data(efc)
data_codebook(efc)
# shorten labels
data_codebook(efc, variable_label_width = 20, value_label_width = 15)
# automatic range for numerics at more than 5 unique values
data(mtcars)
data_codebook(mtcars, select = starts_with("c"))
# force all values to be displayed
data_codebook(mtcars, select = starts_with("c"), range_at = 100)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.