Save Table
sbf_save_table.RdSaves a data frame as .rds and .csv files with the unrounded values
and as a .md file with the values rounded and formatted for display.
Usage
sbf_save_table(
x,
x_name = substitute(x),
sub = sbf_get_sub(),
main = sbf_get_main(),
caption = "",
report = TRUE,
tag = "",
notes = "",
proportion = FALSE,
format_column = list(),
round_as_estimate = character(0)
)Arguments
- x
The data frame to save.
- x_name
A string of the name.
- sub
A string or character vector specifying the path to the sub folder (by default the current sub folder).
- main
A string specifying the path to the main folder (by default the current main folder)
- caption
A string of the caption.
- report
A flag specifying whether to include in a report.
- tag
A string of the tag.
- notes
A string of additional notes to save with the metadata.
- proportion
A flag specifying whether the columns
estimate,lower,upperandsdare proportions, in which case significant digits are counted from the nearer of 0 and 1 in the.mdfile.- format_column
A list of two-sided formulas of the form
column ~ fun(.)specifying how to round and format numeric columns other thanestimate,lower,upperandsdin the.mdfile. The function can return a numeric vector, which is formatted without further rounding, or a character vector, which is used as is. The values in the.rdsand.csvfiles are not altered.- round_as_estimate
A character vector of numeric columns, other than
estimate,lower,upper,sdandsvalue, to round in the.mdfile to the same number of decimal places asestimatein the same row (e.g. anobservedvalue compared with the estimate). Rows with a missing estimate are formatted as data. Ifproportion = TRUEthe columns must also be proportions.
Details
In the .md file, estimates are rounded following the rounding policy in
the usepois report template, which is adapted from Cole (2015).
The column estimate is rounded to the second significant digit of the
column sd if present and otherwise of 1/4 of the interval between the
columns lower and upper.
The columns lower and upper are rounded to one fewer decimal place than
the estimate but to at least two significant digits.
Estimates without an sd or interval are rounded to three significant
digits.
The column svalue is rounded to one decimal place.
Other double columns are rounded to four significant digits, without
adding trailing zeros beyond the digits of the value, while integer columns
are not rounded.
Significant trailing zeros are retained, commas are used as thousands
separators only for numbers of 10,000 or more, and numeric columns are
padded with spaces to align their decimal points.
The .md file is not saved if getOption("sbf.save_md") is FALSE.
References
Cole, T.J. 2015. Too many digits: the presentation of numerical data. Archives of Disease in Childhood 100(7): 608-609. doi:10.1136/archdischild-2014-307149 .
See also
Other save functions:
sbf_basename_sans_ext(),
sbf_save_aws_files(),
sbf_save_block(),
sbf_save_data(),
sbf_save_data_to_db(),
sbf_save_data_to_pg(),
sbf_save_datas(),
sbf_save_datas_to_db(),
sbf_save_db_metatable_descriptions(),
sbf_save_db_to_workbook(),
sbf_save_excel(),
sbf_save_excels(),
sbf_save_gpkg(),
sbf_save_gpkgs(),
sbf_save_number(),
sbf_save_numbers(),
sbf_save_object(),
sbf_save_objects(),
sbf_save_plot(),
sbf_save_png(),
sbf_save_spatial(),
sbf_save_spatials(),
sbf_save_string(),
sbf_save_strings(),
sbf_save_window(),
sbf_save_workbook()