Skip to contents

Color the background cells based on how the value compares to the project average. The project average must be the last row of the table. A footnote is added to the table describing what the dark and light colors mean.

Usage

format_ft_colors(
  ft,
  lighter_color = "#F2F0E6",
  darker_color = "#ccc29c",
  language = "English"
)

Arguments

ft

Flextable object

lighter_color

Lighter background color. Defaults to WaSHI cream.

darker_color

Darker background color. Defaults to WaSHI tan.

language

Language of the footnote. "English" (default) or "Spanish".

Examples

# Read in wrangled example table data
tables_path <- soils_example("tables.RDS")
tables <- readRDS(tables_path)

# Make the table
ft <- flextable::flextable(tables$biological)
ft

Field or Average

Organic Matter

Min C

POXC

PMN

ACE Protein

Field 01

4.5

36

500

67

6.7

Field 03

6.7

51

550

110

4.2

Hay/Silage Average
(14 Fields)

5.5

37

500

92

7.8

Pasture, Seeded Average
(16 Fields)

5.5

58

520

140

7.3

County 9 Average
(5 Fields)

4.7

50

490

79

5.3

Project Average
(100 Fields)

5.8

50

530

99

8.5

# Conditionally format background cell colors format_ft_colors(ft)

Field or Average

Organic Matter

Min C

POXC

PMN

ACE Protein

Field 01

4.5

36

500

67

6.7

Field 03

6.7

51

550

110

4.2

Hay/Silage Average
(14 Fields)

5.5

37

500

92

7.8

Pasture, Seeded Average
(16 Fields)

5.5

58

520

140

7.3

County 9 Average
(5 Fields)

4.7

50

490

79

5.3

Project Average
(100 Fields)

5.8

50

530

99

8.5

Values ≥ project average have darker backgrounds.
Values < project average have lighter backgrounds.