Function to write a table into xml format in the correct directory, and record the calling program in the meta_table.
Source:R/write_table.R
write_table.RdFunction to write a table into xml format in the correct directory, and record the calling program in the meta_table.
Arguments
- x
the data.frame or table to be saved in xml format
- number
the number used as a suffix in the output filename, and to link to the meta_table. Default is to use the value in the cctu_env package environment that is set within
attach_pop.- heading
character vector of column titles. Defaults to the colnames of x
- na_to_empty
logical, if true then any NA values will be written as empty strings. Defaults to false.
- clean_up
logical to invoke the
clean_upfunction at the end. Defaults toTRUE.- directory
where to save the table within path or current working directory. Defaults to
file.path(cctu_opt("output"), "Core").- verbose
logical to print information on changes to the global environment or external files. Defaults to
options()$verbose.- footnote
character vector, can be used to add footnotes. Use
@ref{number}anywhere in the text to insert a clickable cross-reference to another table or figure by its number, e.g."See @ref{1.1} for details"renders as"See Table 1.1 for details"with "Table 1.1" linking to that table's heading.- spanner_sep
NULL(default) for a single-row header, byte-for-byte as before. A separator string (e.g."_") builds a two-level header by splitting each data-column name on its first occurrence of the separator: the text before becomes a group spanner above, the text after the leaf label below. Column 1 is always the row label and is never split. Useful forshift_tableoutput withcol_groups, whose columns are namedgroup_leaf.
Value
writes an xml version of the input data to file table_number.xml. Records the calling program in the meta_table. No return object.
Details
For the plain (non-styled) path, variable names and values are replaced
by variable labels and value labels respectively before writing.
For a cttab input the labels were already baked in upstream by
cttab_format. Set cctu_options(na_to_empty = TRUE)
(or options(cctu_na_to_empty = TRUE)) to make NA-to-empty the
global default.