library(reporter)
library(magrittr)
# Create a temporary file
tmp <- file.path(tempdir(), "bod.txt")
# Define table
tbl <- create_table(BOD, width = 2.5) %>%
titles("Table 3.6", "BOD* Sample Report") %>%
define(Time, format = "Day %s", align = "left") %>%
define(demand, format = "%2.1f mg/l", label = "Demand") %>%
footnotes("* Biochemical Oxygen Demand")
# Define report #1 - No blank margins
rpt <- create_report(tmp, orientation="portrait") %>%
add_content(tbl, align = "left")
# Write the report
write_report(rpt)
# Write report to console
writeLines(readLines(tmp, encoding = "UTF-8"))
# Table 3.6
# BOD* Sample Report
#
# Time Demand
# ----------------------------
# Day 1 8.3 mg/l
# Day 2 10.3 mg/l
# Day 3 19.0 mg/l
# Day 4 16.0 mg/l
# Day 5 15.6 mg/l
# Day 7 19.8 mg/l
#
# * Biochemical Oxygen Demand
# Define report #2 - blank margins
rpt <- create_report(tmp, orientation="portrait") %>%
options_fixed(blank_margins = TRUE) %>%
set_margins(top = .5, left = 1) %>%
add_content(tbl, align = "left")
# Write the report
write_report(rpt)
# Write report to console
writeLines(readLines(tmp, encoding = "UTF-8"))
#
#
#
# Table 3.6
# BOD* Sample Report
#
# Time Demand
# ----------------------------
# Day 1 8.3 mg/l
# Day 2 10.3 mg/l
# Day 3 19.0 mg/l
# Day 4 16.0 mg/l
# Day 5 15.6 mg/l
# Day 7 19.8 mg/l
#
# * Biochemical Oxygen Demand
Run the code above in your browser using DataLab