This is the table making function.

epitable(x, rownamesvar, rownames, colnames = NULL, colgroups = NULL,
  select = NULL, rowlevels = NULL, header = TRUE, file = NULL,
  selfcontained = FALSE, ...)

# S3 method for epitable
knit_print(x, ...)

# S3 method for epitable
print(x, useViewer = TRUE)

Arguments

x

is the data

rownamesvar

variable name in x that identifies the rownames (either rownamesvar or rownames is required)

rownames

vector that identifies the rownames (either rownames or rownamesvar is required)

colnames

vector of column names

colgroups

is a list of two specifically named vectors, names and pattern, that determine the column group names and the spanning pattern. The spanning pattern is the number of columns grouped under each column group. For example, colgroups = list(names = c("a group" "another group"), pattern = c(3, 2)) establishes two column groups, spanning 3 and 2 columns, respectively. See the vignettes for more examples.

rowlevels

is a vector of integers indicating the indentation level (row-level) of each row. EPI's CSS allows for row levels 1 through 4.

header

Set to FALSE if you want suppress the column headers.

file

is the filename for saving the table snippet as a file. By default, this is NULL and epitable() does not write to a file.

selfcontained

If writing to file, the default selfcontained=FALSE will write a table snippet. selfcontained=TRUE writes a complete html page, with header, body, etc.

useViewer

When wrapping epitable in a print() command, set to FALSE to show snippet in console.

extrarowX

is used to add an extra row before row X of the table. See the vignettes for examples.

Examples

# The output will print to the Rstudio viewer: epitable(tradebalance, rownamesvar = industry) # The output will print to the console: print(epitable(tradebalance, rownamesvar = industry), useViewer=FALSE)
#> <table> #> #> <thead> #> <tr><th scope="col"></th> <th scope="col" style="text-align: right;" > import_level </th> <th scope="col" style="text-align: right;" > import_share </th> <th scope="col" style="text-align: right;" > export_level </th> <th scope="col" style="text-align: right;" > export_share </th> <th scope="col" style="text-align: right;" > balance_level </th> <th scope="col" style="text-align: right;" > balance_share </th></tr> #> </thead> #> #> <tbody> #> <tr> #> <th style="min-width:12em;" scope="row">Total change</th> #> <td style="font-variant-numeric: tabular-nums; text-align: right;" > 403.2 </td> #> <td style="font-variant-numeric: tabular-nums; text-align: right;" > 1 </td> #> <td style="font-variant-numeric: tabular-nums; text-align: right;" > 111.1 </td> #> <td style="font-variant-numeric: tabular-nums; text-align: right;" > 1 </td> #> <td style="font-variant-numeric: tabular-nums; text-align: right;" > -292.1 </td> #> <td style="font-variant-numeric: tabular-nums; text-align: right;" > 1 </td> #> </tr> #> <tr> #> <th style="min-width:12em;" scope="row">Agriculture, forestry, fishing, and hunting</th> #> <td style="font-variant-numeric: tabular-nums; text-align: right;" > 2.3 </td> #> <td style="font-variant-numeric: tabular-nums; text-align: right;" > 0.006 </td> #> <td style="font-variant-numeric: tabular-nums; text-align: right;" > 17.3 </td> #> <td style="font-variant-numeric: tabular-nums; text-align: right;" > 0.156 </td> #> <td style="font-variant-numeric: tabular-nums; text-align: right;" > 15 </td> #> <td style="font-variant-numeric: tabular-nums; text-align: right;" > -0.051 </td> #> </tr> #> <tr> #> <th style="min-width:12em;" scope="row">Mining</th> #> <td style="font-variant-numeric: tabular-nums; text-align: right;" > -0.1 </td> #> <td style="font-variant-numeric: tabular-nums; text-align: right;" > 0 </td> #> <td style="font-variant-numeric: tabular-nums; text-align: right;" > 8.5 </td> #> <td style="font-variant-numeric: tabular-nums; text-align: right;" > 0.077 </td> #> <td style="font-variant-numeric: tabular-nums; text-align: right;" > 8.6 </td> #> <td style="font-variant-numeric: tabular-nums; text-align: right;" > -0.03 </td> #> </tr> #> <tr> #> <th style="min-width:12em;" scope="row">Oil and gas</th> #> <td style="font-variant-numeric: tabular-nums; text-align: right;" > 0.1 </td> #> <td style="font-variant-numeric: tabular-nums; text-align: right;" > 0 </td> #> <td style="font-variant-numeric: tabular-nums; text-align: right;" > 6.8 </td> #> <td style="font-variant-numeric: tabular-nums; text-align: right;" > 0.062 </td> #> <td style="font-variant-numeric: tabular-nums; text-align: right;" > 6.8 </td> #> <td style="font-variant-numeric: tabular-nums; text-align: right;" > -0.023 </td> #> </tr> #> <tr> #> <th style="min-width:12em;" scope="row">Minerals and ores</th> #> <td style="font-variant-numeric: tabular-nums; text-align: right;" > 0.1 </td> #> <td style="font-variant-numeric: tabular-nums; text-align: right;" > 0 </td> #> <td style="font-variant-numeric: tabular-nums; text-align: right;" > 1.7 </td> #> <td style="font-variant-numeric: tabular-nums; text-align: right;" > 0.015 </td> #> <td style="font-variant-numeric: tabular-nums; text-align: right;" > 1.6 </td> #> <td style="font-variant-numeric: tabular-nums; text-align: right;" > -0.005 </td> #> </tr> #> <tr> #> <th style="min-width:12em;" scope="row">Manufacturing</th> #> <td style="font-variant-numeric: tabular-nums; text-align: right;" > 400.8 </td> #> <td style="font-variant-numeric: tabular-nums; text-align: right;" > 0.994 </td> #> <td style="font-variant-numeric: tabular-nums; text-align: right;" > 80 </td> #> <td style="font-variant-numeric: tabular-nums; text-align: right;" > 0.72 </td> #> <td style="font-variant-numeric: tabular-nums; text-align: right;" > -320.8 </td> #> <td style="font-variant-numeric: tabular-nums; text-align: right;" > 1.098 </td> #> </tr> #> <tr> #> <th style="min-width:12em;" scope="row">Nondurable goods</th> #> <td style="font-variant-numeric: tabular-nums; text-align: right;" > 44.1 </td> #> <td style="font-variant-numeric: tabular-nums; text-align: right;" > 0.109 </td> #> <td style="font-variant-numeric: tabular-nums; text-align: right;" > 3.5 </td> #> <td style="font-variant-numeric: tabular-nums; text-align: right;" > 0.032 </td> #> <td style="font-variant-numeric: tabular-nums; text-align: right;" > -40.6 </td> #> <td style="font-variant-numeric: tabular-nums; text-align: right;" > 0.139 </td> #> </tr> #> <tr> #> <th style="min-width:12em;" scope="row">Food</th> #> <td style="font-variant-numeric: tabular-nums; text-align: right;" > 3.2 </td> #> <td style="font-variant-numeric: tabular-nums; text-align: right;" > 0.008 </td> #> <td style="font-variant-numeric: tabular-nums; text-align: right;" > 2.5 </td> #> <td style="font-variant-numeric: tabular-nums; text-align: right;" > 0.023 </td> #> <td style="font-variant-numeric: tabular-nums; text-align: right;" > -0.6 </td> #> <td style="font-variant-numeric: tabular-nums; text-align: right;" > 0.002 </td> #> </tr> #> <tr> #> <th style="min-width:12em;" scope="row">Beverage and tobacco products</th> #> <td style="font-variant-numeric: tabular-nums; text-align: right;" > 0.1 </td> #> <td style="font-variant-numeric: tabular-nums; text-align: right;" > 0 </td> #> <td style="font-variant-numeric: tabular-nums; text-align: right;" > 0.2 </td> #> <td style="font-variant-numeric: tabular-nums; text-align: right;" > 0.002 </td> #> <td style="font-variant-numeric: tabular-nums; text-align: right;" > 0.1 </td> #> <td style="font-variant-numeric: tabular-nums; text-align: right;" > 0 </td> #> </tr> #> <tr> #> <th style="min-width:12em;" scope="row">Textile mills and textile product mills</th> #> <td style="font-variant-numeric: tabular-nums; text-align: right;" > 11.8 </td> #> <td style="font-variant-numeric: tabular-nums; text-align: right;" > 0.029 </td> #> <td style="font-variant-numeric: tabular-nums; text-align: right;" > 0.4 </td> #> <td style="font-variant-numeric: tabular-nums; text-align: right;" > 0.004 </td> #> <td style="font-variant-numeric: tabular-nums; text-align: right;" > -11.4 </td> #> <td style="font-variant-numeric: tabular-nums; text-align: right;" > 0.039 </td> #> </tr> #> <tr> #> <th style="min-width:12em;" scope="row">Apparel</th> #> <td style="font-variant-numeric: tabular-nums; text-align: right;" > 20.7 </td> #> <td style="font-variant-numeric: tabular-nums; text-align: right;" > 0.051 </td> #> <td style="font-variant-numeric: tabular-nums; text-align: right;" > 0.1 </td> #> <td style="font-variant-numeric: tabular-nums; text-align: right;" > 0.001 </td> #> <td style="font-variant-numeric: tabular-nums; text-align: right;" > -20.7 </td> #> <td style="font-variant-numeric: tabular-nums; text-align: right;" > 0.071 </td> #> </tr> #> <tr> #> <th style="min-width:12em;" scope="row">Leather and allied products</th> #> <td style="font-variant-numeric: tabular-nums; text-align: right;" > 8.3 </td> #> <td style="font-variant-numeric: tabular-nums; text-align: right;" > 0.02 </td> #> <td style="font-variant-numeric: tabular-nums; text-align: right;" > 0.3 </td> #> <td style="font-variant-numeric: tabular-nums; text-align: right;" > 0.003 </td> #> <td style="font-variant-numeric: tabular-nums; text-align: right;" > -7.9 </td> #> <td style="font-variant-numeric: tabular-nums; text-align: right;" > 0.027 </td> #> </tr> #> </tbody> #> </table>