htmlTable_td: Generate an htmlTable using a ggplot2-like interface

Description Usage Arguments Value Column-mapping parameters Hidden value See Also Examples

View source: R/htmlTable_td.R

Description

Builds an htmlTable by mapping columns from the input data, x, to elements of an output htmlTable (e.g. rnames_td, header_td, etc.)

Usage

1
2
3
4
htmlTable_td(x, cell_value = "cell_value", header_td = "header_td",
  rnames_td = "rnames_td", rgroup_td = NULL, hidden_rgroup_td = NULL,
  cgroup1_td = NULL, cgroup2_td = NULL, tspanner_td = NULL,
  hidden_tspanner_td = NULL, ...)

Arguments

x

Tidy data used to build the htmlTable

cell_value

The column containing values filling individual cells of the output htmlTable

header_td

The column in x specifying column headings

rnames_td

The column in x specifying row names

rgroup_td

The column in x specifying row groups

hidden_rgroup_td

rgroup_td values that will be hidden.

cgroup1_td

The column in x specifying the inner most column groups

cgroup2_td

The column in x specifying the outer most column groups

tspanner_td

The column in x specifying tspanner_td groups

hidden_tspanner_td

tspanner_td values that will be hidden.

...

Additional arguments that will be passed to the inner htmlTable function

Value

Returns html code that will build a pretty table

Column-mapping parameters

The htmlTable_td function is designed to work like ggplot2 in that columns from x are mapped to specific parameters from the htmlTable function. At minimum, x must contain the names of columns mapping to rnames_td, header_td, and rnames_td. header_td and rnames_td retain the same meaning as in the htmlTable function. cell_value contains the individual values that will be used to fill each cell within the output htmlTable.

A full list of parameters from htmlTable which may be mapped to columns within x include:

Note that unlike in htmlTable which contains cgroup, and which may specify a variable number of column groups, htmlTable_td contains the parameters cgroup1_td and cgroup2_td. These parameters correspond to the inward most and outward most column groups respectively.

Also note that the coordinates of each cell_value within x must be unambiguously mapped to a position within the output htmlTable. Therefore, the each row-wise combination the variables specified above contained in x must be unique.

Hidden value

htmlTable Allows for some values within rgroup_td, cgroup, etc. to be specified as "". The following parameters allow for specific values to be treated as if they were a string of length zero in the htmlTable function.

See Also

htmlTable

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
## Not run: 
library(tidyverse)
mtcars %>%
    rownames_to_column %>%
    select(rowname, cyl, gear, hp, mpg, qsec) %>%
    gather(per_metric, cell_value, hp, mpg, qsec) %>%
    group_by(cyl, gear, per_metric) %>%
    summarise(Mean = round(mean(cell_value), 1),
              SD = round(sd(cell_value), 1),
              Min = round(min(cell_value), 1),
              Max = round(max(cell_value), 1)) %>%
     gather(summary_stat, cell_value, Mean, SD, Min, Max) %>%
     ungroup %>%
     mutate(gear = paste(gear, "Gears"),
            cyl = paste(cyl, "Cylinders")) %>%
     htmlTable_td(header_td = "gear",
                  cgroup1_td = "cyl",
                  cell_value = "cell_value",
                  rnames_td = "summary_stat",
                  rgroup_td = "per_metric")

## End(Not run)

graggsd/tidyhTbl documentation built on May 28, 2019, 8:54 p.m.