htmlTable/ 0000755 0001762 0000144 00000000000 14517543722 012200 5 ustar ligges users htmlTable/NAMESPACE 0000644 0001762 0000144 00000003212 14517434555 013420 0 ustar ligges users # Generated by roxygen2: do not edit by hand
S3method(htmlTable,data.frame)
S3method(htmlTable,default)
S3method(htmlTable,matrix)
S3method(interactiveTable,default)
S3method(interactiveTable,htmlTable)
S3method(knit_print,htmlTable)
S3method(knit_print,interactiveTable)
S3method(print,htmlTable)
S3method(print,interactiveTable)
S3method(tidyHtmlTable,data.frame)
S3method(tidyHtmlTable,default)
S3method(txtRound,data.frame)
S3method(txtRound,default)
S3method(txtRound,matrix)
S3method(txtRound,table)
export(addHtmlTableStyle)
export(concatHtmlTables)
export(getHtmlTableStyle)
export(getHtmlTableTheme)
export(hasHtmlTableStyle)
export(htmlTable)
export(htmlTableWidget)
export(htmlTableWidgetOutput)
export(interactiveTable)
export(outputInt)
export(prepGroupCounts)
export(pvalueFormatter)
export(renderHtmlTableWidget)
export(setHtmlTableTheme)
export(splitLines4Table)
export(tblNoLast)
export(tblNoNext)
export(tidyHtmlTable)
export(txtInt)
export(txtMergeLines)
export(txtPval)
export(txtRound)
export(vector2string)
import(checkmate)
import(htmlwidgets)
import(magrittr)
importFrom(grDevices,col2rgb)
importFrom(grDevices,colorRampPalette)
importFrom(htmltools,htmlEscape)
importFrom(knitr,asis_output)
importFrom(knitr,knit_print)
importFrom(methods,formalArgs)
importFrom(methods,setClass)
importFrom(rstudioapi,getActiveDocumentContext)
importFrom(rstudioapi,isAvailable)
importFrom(stats,na.omit)
importFrom(stringr,str_interp)
importFrom(stringr,str_replace)
importFrom(stringr,str_replace_all)
importFrom(stringr,str_split)
importFrom(stringr,str_trim)
importFrom(utils,as.roman)
importFrom(utils,browseURL)
importFrom(utils,head)
importFrom(utils,tail)
htmlTable/README.md 0000644 0001762 0000144 00000151007 14517463044 013461 0 ustar ligges users [](https://cran.r-project.org/package=htmlTable)
# Basics
The **htmlTable** package is intended for generating tables using [HTML](https://en.wikipedia.org/wiki/HTML) formatting. This format is compatible with [Markdown](https://rmarkdown.rstudio.com/) when used for HTML-output. The most basic table can easily be created by just passing a `matrix` or a `data.frame` to the `htmlTable`-function:
```r
library(magrittr)
library(htmlTable)
# A simple output
output <- matrix(1:4,
ncol=2,
dimnames = list(list("Row 1", "Row 2"),
list("Column 1", "Column 2")))
htmlTable(output)
```
|
Column 1 |
Column 2 |
Row 1 |
1 |
3 |
Row 2 |
2 |
4 |
If you are using `dplyr` and `tidyverse` a convenient wrapper is the `tidyHtmlTable` function (check out `vignette("tidyHtmlTable")`). A simple example of the `tidyHtmlTable` would look something like this:
```r
library(tidyverse)
library(glue)
mtcars |>
as_tibble(rownames = "rnames") |>
filter(cyl == 6 & qsec < 18) |>
pivot_longer(names_to = "per_metric",
cols = c(hp, mpg, qsec)) |>
arrange(gear, rnames) |>
mutate(gear = glue("{gear} gears")) |>
addHtmlTableStyle(align = "r") |>
tidyHtmlTable(header = per_metric, rnames = rnames, rgroup = gear,
caption = "A simple tidyHtmlTable
example using mtcars
")
```
A simple tidyHtmlTable example using mtcars
|
|
hp |
mpg |
qsec |
4 gears |
Mazda RX4 |
110 |
21 |
16.46 |
Mazda RX4 Wag |
110 |
21 |
17.02 |
5 gears |
Ferrari Dino |
175 |
19.7 |
15.5 |
# Advanced
While it may be sufficient for basic tables a more advanced layout is often needed in medical publications with elements such as:
- row groups
- column spanners
- table spanners
- caption
- table footer
- zebra coloring (also know as _banding_):
- rows
- columns
As many journals require that a MS Word-document is submitted it is furthermore also important that the table imports correctly to a word processor, i.e. that the table doesn't only look nice in a web browser but also in the final document. The `htmlTable`-function is written for all these purposes.
**Note:** Due to GitHub CSS-styles the rows get automatically zebra-striped (in a bad way), borders get overridden and I haven't been able to figure out how to change this. See the vignette for a correct example: `vignette("general", package = "htmlTable")`
For demonstration purposes we will setup a basic matrix:
```r
mx <-
matrix(ncol=6, nrow=8) |>
set_rownames(paste(c("1st", "2nd", "3rd",
paste0(4:8, "th")),
"row")) |>
set_colnames(paste(c("1st", "2nd", "3rd",
paste0(4:6, "th")),
"hdr"))
for (nr in 1:nrow(mx)){
for (nc in 1:ncol(mx)){
mx[nr, nc] <-
paste0(nr, ":", nc)
}
}
```
## Row groups
The purpose of the row groups is to group variables that belong to the same group, e.g. a factored variable with more than two levels often benefit from grouping variables together.
```r
htmlTable(mx,
rgroup = paste("Group", LETTERS[1:3]),
n.rgroup = c(2,4,nrow(mx) - 6))
```
|
1st hdr |
2nd hdr |
3rd hdr |
4th hdr |
5th hdr |
6th hdr |
Group A |
1st row |
1:1 |
1:2 |
1:3 |
1:4 |
1:5 |
1:6 |
2nd row |
2:1 |
2:2 |
2:3 |
2:4 |
2:5 |
2:6 |
Group B |
3rd row |
3:1 |
3:2 |
3:3 |
3:4 |
3:5 |
3:6 |
4th row |
4:1 |
4:2 |
4:3 |
4:4 |
4:5 |
4:6 |
5th row |
5:1 |
5:2 |
5:3 |
5:4 |
5:5 |
5:6 |
6th row |
6:1 |
6:2 |
6:3 |
6:4 |
6:5 |
6:6 |
Group C |
7th row |
7:1 |
7:2 |
7:3 |
7:4 |
7:5 |
7:6 |
8th row |
8:1 |
8:2 |
8:3 |
8:4 |
8:5 |
8:6 |
We can easily mix row groups with regular variables by having an empty row group name `""`:
```r
htmlTable(mx,
rgroup = c(paste("Group", LETTERS[1:2]), ""),
n.rgroup = c(2,4,nrow(mx) - 6))
```
|
1st hdr |
2nd hdr |
3rd hdr |
4th hdr |
5th hdr |
6th hdr |
Group A |
1st row |
1:1 |
1:2 |
1:3 |
1:4 |
1:5 |
1:6 |
2nd row |
2:1 |
2:2 |
2:3 |
2:4 |
2:5 |
2:6 |
Group B |
3rd row |
3:1 |
3:2 |
3:3 |
3:4 |
3:5 |
3:6 |
4th row |
4:1 |
4:2 |
4:3 |
4:4 |
4:5 |
4:6 |
5th row |
5:1 |
5:2 |
5:3 |
5:4 |
5:5 |
5:6 |
6th row |
6:1 |
6:2 |
6:3 |
6:4 |
6:5 |
6:6 |
7th row |
7:1 |
7:2 |
7:3 |
7:4 |
7:5 |
7:6 |
8th row |
8:1 |
8:2 |
8:3 |
8:4 |
8:5 |
8:6 |
When mixing row groups with variables without row groups we may want to omit the bold formatting of the row group label. As of htmlTable version 2.0
you can separate the css styling using `addHtmlTableStyle`:
```r
mx |>
addHtmlTableStyle(css.rgroup = "") |>
htmlTable(rgroup = c(paste("Group", LETTERS[1:2]), ""),
n.rgroup = c(2,4,nrow(mx) - 6))
```
|
1st hdr |
2nd hdr |
3rd hdr |
4th hdr |
5th hdr |
6th hdr |
Group A |
1st row |
1:1 |
1:2 |
1:3 |
1:4 |
1:5 |
1:6 |
2nd row |
2:1 |
2:2 |
2:3 |
2:4 |
2:5 |
2:6 |
Group B |
3rd row |
3:1 |
3:2 |
3:3 |
3:4 |
3:5 |
3:6 |
4th row |
4:1 |
4:2 |
4:3 |
4:4 |
4:5 |
4:6 |
5th row |
5:1 |
5:2 |
5:3 |
5:4 |
5:5 |
5:6 |
6th row |
6:1 |
6:2 |
6:3 |
6:4 |
6:5 |
6:6 |
7th row |
7:1 |
7:2 |
7:3 |
7:4 |
7:5 |
7:6 |
8th row |
8:1 |
8:2 |
8:3 |
8:4 |
8:5 |
8:6 |
## Column spanners
A column spanner spans 2 or more columns:
```r
htmlTable(mx,
cgroup = c("Cgroup 1", "Cgroup 2"),
n.cgroup = c(2,4))
```
|
Cgroup 1 | |
Cgroup 2 |
|
1st hdr |
2nd hdr |
|
3rd hdr |
4th hdr |
5th hdr |
6th hdr |
1st row |
1:1 |
1:2 |
|
1:3 |
1:4 |
1:5 |
1:6 |
2nd row |
2:1 |
2:2 |
|
2:3 |
2:4 |
2:5 |
2:6 |
3rd row |
3:1 |
3:2 |
|
3:3 |
3:4 |
3:5 |
3:6 |
4th row |
4:1 |
4:2 |
|
4:3 |
4:4 |
4:5 |
4:6 |
5th row |
5:1 |
5:2 |
|
5:3 |
5:4 |
5:5 |
5:6 |
6th row |
6:1 |
6:2 |
|
6:3 |
6:4 |
6:5 |
6:6 |
7th row |
7:1 |
7:2 |
|
7:3 |
7:4 |
7:5 |
7:6 |
8th row |
8:1 |
8:2 |
|
8:3 |
8:4 |
8:5 |
8:6 |
It can sometimes be convenient to have column spanners in multiple levels:
```r
htmlTable(mx,
cgroup = rbind(c("", "Column spanners", NA),
c("", "Cgroup 1", "Cgroup 2")),
n.cgroup = rbind(c(1,2,NA),
c(2,2,2)))
```
|
| |
Column spanners |
|
| |
Cgroup 1 | |
Cgroup 2 |
|
1st hdr |
2nd hdr |
|
3rd hdr |
4th hdr |
|
5th hdr |
6th hdr |
1st row |
1:1 |
1:2 |
|
1:3 |
1:4 |
|
1:5 |
1:6 |
2nd row |
2:1 |
2:2 |
|
2:3 |
2:4 |
|
2:5 |
2:6 |
3rd row |
3:1 |
3:2 |
|
3:3 |
3:4 |
|
3:5 |
3:6 |
4th row |
4:1 |
4:2 |
|
4:3 |
4:4 |
|
4:5 |
4:6 |
5th row |
5:1 |
5:2 |
|
5:3 |
5:4 |
|
5:5 |
5:6 |
6th row |
6:1 |
6:2 |
|
6:3 |
6:4 |
|
6:5 |
6:6 |
7th row |
7:1 |
7:2 |
|
7:3 |
7:4 |
|
7:5 |
7:6 |
8th row |
8:1 |
8:2 |
|
8:3 |
8:4 |
|
8:5 |
8:6 |
Above example allows the column spanner to be a sum of the underlying cgroups (see n.cgroup), this is not required by the function:
```r
htmlTable(mx,
cgroup = rbind(c("", "Column spanners", NA),
c("", "Cgroup 1", "Cgroup 2")),
n.cgroup = rbind(c(1,5,NA),
c(2,1,3)))
```
|
| |
Column spanners |
|
| |
Cgroup 1 | |
Cgroup 2 |
|
1st hdr |
|
2nd hdr |
|
3rd hdr |
|
4th hdr |
5th hdr |
6th hdr |
1st row |
1:1 |
|
1:2 |
|
1:3 |
|
1:4 |
1:5 |
1:6 |
2nd row |
2:1 |
|
2:2 |
|
2:3 |
|
2:4 |
2:5 |
2:6 |
3rd row |
3:1 |
|
3:2 |
|
3:3 |
|
3:4 |
3:5 |
3:6 |
4th row |
4:1 |
|
4:2 |
|
4:3 |
|
4:4 |
4:5 |
4:6 |
5th row |
5:1 |
|
5:2 |
|
5:3 |
|
5:4 |
5:5 |
5:6 |
6th row |
6:1 |
|
6:2 |
|
6:3 |
|
6:4 |
6:5 |
6:6 |
7th row |
7:1 |
|
7:2 |
|
7:3 |
|
7:4 |
7:5 |
7:6 |
8th row |
8:1 |
|
8:2 |
|
8:3 |
|
8:4 |
8:5 |
8:6 |
## Table spanners
A table spanner is similar to rgroup but has the primary purpose of combining 2 or more tables with the same columns into one:
```r
htmlTable(mx,
tspanner = paste("Spanner", LETTERS[1:3]),
n.tspanner = c(2,4,nrow(mx) - 6))
```
|
1st hdr |
2nd hdr |
3rd hdr |
4th hdr |
5th hdr |
6th hdr |
Spanner A |
1st row |
1:1 |
1:2 |
1:3 |
1:4 |
1:5 |
1:6 |
2nd row |
2:1 |
2:2 |
2:3 |
2:4 |
2:5 |
2:6 |
Spanner B |
3rd row |
3:1 |
3:2 |
3:3 |
3:4 |
3:5 |
3:6 |
4th row |
4:1 |
4:2 |
4:3 |
4:4 |
4:5 |
4:6 |
5th row |
5:1 |
5:2 |
5:3 |
5:4 |
5:5 |
5:6 |
6th row |
6:1 |
6:2 |
6:3 |
6:4 |
6:5 |
6:6 |
Spanner C |
7th row |
7:1 |
7:2 |
7:3 |
7:4 |
7:5 |
7:6 |
8th row |
8:1 |
8:2 |
8:3 |
8:4 |
8:5 |
8:6 |
## Table caption
The table caption is simply the table description and can be either located above or below the table:
```r
htmlTable(mx[1:2,1:2],
caption="A table caption above")
```
Table 5: A table caption above |
|
1st hdr |
2nd hdr |
1st row |
1:1 |
1:2 |
2nd row |
2:1 |
2:2 |
```r
mx[1:2,1:2] |>
addHtmlTableStyle(pos.caption = "bottom") |>
htmlTable(caption="A table caption below")
```
|
1st hdr |
2nd hdr |
1st row |
1:1 |
1:2 |
2nd row |
2:1 |
2:2 |
Table 6: A table caption below |
A more interesting detail that the function allows for is table numbering, initialized by:
```r
options(table_counter = TRUE)
```
```r
htmlTable(mx[1:2,1:2],
caption="A table caption with a numbering")
```
Table 1: A table caption with a numbering |
|
1st hdr |
2nd hdr |
1st row |
1:1 |
1:2 |
2nd row |
2:1 |
2:2 |
As we often want to reference the table number in the text there are two associated functions:
```r
tblNoLast()
```
```
## [1] 1
```
```r
tblNoNext()
```
```
## [1] 2
```
## Table footer
The footer usually contains specifics regarding variables and is always located at the foot of the table:
```r
htmlTable(mx[1:2,1:2],
tfoot="A table footer")
```
|
1st hdr |
2nd hdr |
1st row |
1:1 |
1:2 |
2nd row |
2:1 |
2:2 |
A table footer |
## Putting it all together
Now if we want to do everything in one table it may look like this:
```r
mx |>
addHtmlTableStyle(col.columns = c(rep("none", 2), rep("#F5FBFF", 4)),
col.rgroup = c("none", "#F7F7F7"),
css.cell = "padding-left: .5em; padding-right: .2em;",
align="r") |>
htmlTable(rgroup = paste("Group", LETTERS[1:3]),
n.rgroup = c(2, 4),
cgroup = rbind(c("", "Column spanners", NA),
c("", "Cgroup 1", "Cgroup 2†")),
n.cgroup = rbind(c(1, 2, NA), c(2, 2, 2)),
caption="A table with column spanners, row groups, and zebra striping",
tfoot="† A table footer commment",
cspan.rgroup = 2)
```
Table 2: A table with column spanners, row groups, and zebra striping |
|
| |
Column spanners |
|
| |
Cgroup 1 | |
Cgroup 2† |
|
1st hdr |
2nd hdr |
|
3rd hdr |
4th hdr |
|
5th hdr |
6th hdr |
Group A |
|
|
|
|
|
|
|
1st row |
1:1 |
1:2 |
|
1:3 |
1:4 |
|
1:5 |
1:6 |
2nd row |
2:1 |
2:2 |
|
2:3 |
2:4 |
|
2:5 |
2:6 |
Group B |
|
|
|
|
|
|
|
3rd row |
3:1 |
3:2 |
|
3:3 |
3:4 |
|
3:5 |
3:6 |
4th row |
4:1 |
4:2 |
|
4:3 |
4:4 |
|
4:5 |
4:6 |
5th row |
5:1 |
5:2 |
|
5:3 |
5:4 |
|
5:5 |
5:6 |
6th row |
6:1 |
6:2 |
|
6:3 |
6:4 |
|
6:5 |
6:6 |
Group C |
|
|
|
|
|
|
|
7th row |
7:1 |
7:2 |
|
7:3 |
7:4 |
|
7:5 |
7:6 |
8th row |
8:1 |
8:2 |
|
8:3 |
8:4 |
|
8:5 |
8:6 |
† A table footer comment |
htmlTable/data/ 0000755 0001762 0000144 00000000000 13407215301 013073 5 ustar ligges users htmlTable/data/SCB.rda 0000644 0001762 0000144 00000001245 13407215301 014174 0 ustar ligges users VMn@8?"VlPV,8Jv{X!NZl;, p \}Ì=kTU)#|/3f/A~PgY\UVnR%Va[
=Uw[Ux[\Oɬ5YeMVZHfU-g' (6¡*5X=^1S04k NhVrlrGyX,]ЬGa
bs^-w htmlTable/man/ 0000755 0001762 0000144 00000000000 14517463044 012751 5 ustar ligges users htmlTable/man/txtRound.Rd 0000644 0001762 0000144 00000007255 14165130172 015070 0 ustar ligges users % Generated by roxygen2: do not edit by hand
% Please edit documentation in R/txtFrmt_round.R, R/txtFrmt_round_data.frame.R
\name{txtRound}
\alias{txtRound}
\alias{txtRound.default}
\alias{txtRound.table}
\alias{txtRound.matrix}
\alias{txtRound.data.frame}
\title{A convenient rounding function}
\usage{
txtRound(x, ...)
\method{txtRound}{default}(
x,
digits = 0,
digits.nonzero = NA,
txt.NA = "",
dec = getOption("htmlTable.decimal_marker", default = "."),
scientific = NULL,
txtInt_args = getOption("htmlTable.round_int", default = NULL),
...
)
\method{txtRound}{table}(x, ...)
\method{txtRound}{matrix}(x, digits = 0, excl.cols = NULL, excl.rows = NULL, ...)
\method{txtRound}{data.frame}(x, ..., digits = 0L)
}
\arguments{
\item{x}{The value/vector/data.frame/matrix to be rounded}
\item{...}{Passed to next method}
\item{digits}{The number of digits to round each element to. For \code{matrix}
or \code{data.frame} input you can provide a \code{vector}/\code{list}. An unnamed \code{vector}/\code{list}
must equal the length of the columns to round. If you provide a named vector you
can provide specify per column the number of digits, and then use \code{.default}
for those columns that we don't need to have separate values for.}
\item{digits.nonzero}{The number of digits to keep if the result is close to
zero. Sometimes we have an entire table with large numbers only to have a
few but interesting observation that are really interesting}
\item{txt.NA}{The string to exchange \code{NA} with}
\item{dec}{The decimal marker. If the text is in non-English decimal
and string formatted you need to change this to the appropriate decimal
indicator. The option for this is \code{htmlTable.decimal_marker}.}
\item{scientific}{If the value should be in scientific format.}
\item{txtInt_args}{A list of arguments to pass to \code{\link[=txtInt]{txtInt()}} if that is to be
used for large values that may require a thousands separator. The option
for this is \code{htmlTable.round_int}. If \code{TRUE} it will activate the \code{txtInt}
functionality.}
\item{excl.cols}{Columns to exclude from the rounding procedure when provided a matrix.
This can be either a number or regular expression. Skipped if \code{x} is a vector.}
\item{excl.rows}{Rows to exclude from the rounding procedure when provided a matrix.
This can be either a number or regular expression.}
}
\value{
\code{matrix/data.frame}
}
\description{
Regular round often looses trailing 0:s as these are truncated, this function
converts everything to strings with all 0:s intact so that tables have the
correct representation, e.g. \code{txtRound(1.01, digits = 1)} turns into \code{1.0}.
}
\section{Tidy-select with \code{data.frame}}{
The \code{txtRound} can use \code{data.frame} for input. This allows us to use
\href{https://tidyselect.r-lib.org/articles/tidyselect.html}{tidyselect}
patterns as popularized by \strong{dplyr}.
}
\examples{
# Basic usage
txtRound(1.023, digits = 1)
# > "1.0"
txtRound(pi, digits = 2)
# > "3.14"
txtRound(12344, digits = 1, txtInt_args = TRUE)
# > "12,344.0"
# Using matrix
mx <- matrix(c(1, 1.11, 1.25,
2.50, 2.55, 2.45,
3.2313, 3, pi),
ncol = 3, byrow=TRUE)
txtRound(mx, digits = 1)
#> [,1] [,2] [,3]
#> [1,] "1.0" "1.1" "1.2"
#> [2,] "2.5" "2.5" "2.5"
#> [3,] "3.2" "3.0" "3.1"
# Using a data.frame directly
library(magrittr)
data("mtcars")
# If we want to round all the numerical values
mtcars \%>\%
txtRound(digits = 1)
# If we want only want to round some columns
mtcars \%>\%
txtRound(wt, qsec_txt = qsec, digits = 1)
}
\seealso{
Other text formatters:
\code{\link{txtInt}()},
\code{\link{txtMergeLines}()},
\code{\link{txtPval}()}
}
\concept{text formatters}
htmlTable/man/prAttr4RgroupAdd.Rd 0000644 0001762 0000144 00000001275 13701421460 016403 0 ustar ligges users % Generated by roxygen2: do not edit by hand
% Please edit documentation in R/htmlTable_helpers_attr4RgroupAdd.R
\name{prAttr4RgroupAdd}
\alias{prAttr4RgroupAdd}
\title{Get the add attribute element}
\usage{
prAttr4RgroupAdd(rgroup, rgroup_iterator, no_cols)
}
\arguments{
\item{rgroup}{A vector of character strings containing headings for row groups.
\code{n.rgroup} must be present when \code{rgroup} is given. See
detailed description in section below.}
\item{rgroup_iterator}{The rgroup number of interest}
\item{no_cols}{The \code{ncol(x)} of the core htmlTable x argument}
}
\description{
Gets the add element attribute if it exists. If non-existant it will
return NULL.
}
\keyword{internal}
htmlTable/man/hasHtmlTableStyle.Rd 0000644 0001762 0000144 00000001552 13730316012 016620 0 ustar ligges users % Generated by roxygen2: do not edit by hand
% Please edit documentation in R/htmlTable_style_handlers.R
\name{hasHtmlTableStyle}
\alias{hasHtmlTableStyle}
\title{Check if object has a style set to it}
\usage{
hasHtmlTableStyle(x, style_name)
}
\arguments{
\item{x}{The object intended for \code{\link[=htmlTable]{htmlTable()}}.}
\item{style_name}{A string that contains the style name.}
}
\value{
\code{logical} \code{TRUE} if the attribute and style is not \code{NULL}
}
\description{
If the attribute \code{htmlTable.style} is set it will check if
the \code{style_name} exists and return a \code{logical}.
}
\examples{
library(magrittr)
mx <- matrix(1:4, ncol = 2)
colnames(mx) <- LETTERS[1:2]
mx \%>\%
addHtmlTableStyle(align = "l|r") \%>\%
hasHtmlTableStyle("align")
}
\seealso{
Other htmlTableStyle:
\code{\link{addHtmlTableStyle}()}
}
\concept{htmlTableStyle}
htmlTable/man/txtPval.Rd 0000644 0001762 0000144 00000003406 13701421460 014673 0 ustar ligges users % Generated by roxygen2: do not edit by hand
% Please edit documentation in R/txtFrmt.R
\name{txtPval}
\alias{txtPval}
\title{Formats the p-values}
\usage{
txtPval(pvalues, lim.2dec = 10^-2, lim.sig = 10^-4, html = TRUE, ...)
}
\arguments{
\item{pvalues}{The p-values}
\item{lim.2dec}{The limit for showing two decimals. E.g.
the p-value may be \code{0.056} and we may want to keep the two decimals in order
to emphasize the proximity to the all-mighty \code{0.05} p-value and set this to
\eqn{10^-2}. This allows that a value of \code{0.0056} is rounded to \code{0.006} and this
makes intuitive sense as the \code{0.0056} level as this is well below
the \code{0.05} value and thus not as interesting to know the exact proximity to
\code{0.05}. \emph{Disclaimer:} The \code{0.05}-limit is really silly and debated, unfortunately
it remains a standard and this package tries to adapt to the current standards in order
to limit publication associated issues.}
\item{lim.sig}{The significance limit for the less than sign, i.e. the '\code{<}'}
\item{html}{If the less than sign should be \code{<} or \verb{<} as needed for HTML output.}
\item{...}{Currently only used for generating warnings of deprecated call parameters.}
}
\value{
vector
}
\description{
Gets formatted p-values. For instance
you often want \code{0.1234} to be \code{0.12} while also
having two values up until a limit,
i.e. \code{0.01234} should be \code{0.012} while
\code{0.001234} should be \code{0.001}. Furthermore you
want to have \verb{< 0.001} as it becomes ridiculous
to report anything below that value.
}
\examples{
txtPval(c(0.10234,0.010234, 0.0010234, 0.000010234))
}
\seealso{
Other text formatters:
\code{\link{txtInt}()},
\code{\link{txtMergeLines}()},
\code{\link{txtRound}()}
}
\concept{text formatters}
htmlTable/man/htmlTable.Rd 0000644 0001762 0000144 00000047404 14517464161 015166 0 ustar ligges users % Generated by roxygen2: do not edit by hand
% Please edit documentation in R/htmlTable.R, R/htmlTable_render_knit_print.R,
% R/htmlTable_render_print.R
\name{htmlTable}
\alias{htmlTable}
\alias{htmlTable.default}
\alias{knit_print.htmlTable}
\alias{print.htmlTable}
\title{Output an HTML table}
\usage{
htmlTable(
x,
header = NULL,
rnames = NULL,
rowlabel = NULL,
caption = NULL,
tfoot = NULL,
label = NULL,
rgroup = NULL,
n.rgroup = NULL,
cgroup = NULL,
n.cgroup = NULL,
tspanner = NULL,
n.tspanner = NULL,
total = NULL,
ctable = TRUE,
compatibility = getOption("htmlTableCompat", "LibreOffice"),
cspan.rgroup = "all",
escape.html = FALSE,
...
)
\method{htmlTable}{default}(
x,
header = NULL,
rnames = NULL,
rowlabel = NULL,
caption = NULL,
tfoot = NULL,
label = NULL,
rgroup = NULL,
n.rgroup = NULL,
cgroup = NULL,
n.cgroup = NULL,
tspanner = NULL,
n.tspanner = NULL,
total = NULL,
ctable = TRUE,
compatibility = getOption("htmlTableCompat", "LibreOffice"),
cspan.rgroup = "all",
escape.html = FALSE,
...
)
\method{knit_print}{htmlTable}(x, ...)
\method{print}{htmlTable}(x, useViewer, ...)
}
\arguments{
\item{x}{The matrix/data.frame with the data. For the \code{print} and \code{knit_print}
it takes a string of the class \code{htmlTable} as \code{x} argument.}
\item{header}{A vector of character strings specifying column
header, defaulting to \code{\link[base:colnames]{colnames(x)}}}
\item{rnames}{Default row names are generated from \code{\link[base:colnames]{rownames(x)}}. If you
provide \code{FALSE} then it will skip the row names. \emph{Note:} For \code{data.frames}
if you do \code{\link[base:colnames]{rownames(my_dataframe) <- NULL}} it still has
row names. Thus you need to use \code{FALSE} if you want to
supress row names for \code{data.frames}.}
\item{rowlabel}{If the table has row names or \code{rnames},
\code{rowlabel} is a character string containing the
column heading for the \code{rnames}.}
\item{caption}{Adds a table caption.}
\item{tfoot}{Adds a table footer (uses the \verb{} HTML element). The
output is run through \code{\link[=txtMergeLines]{txtMergeLines()}} simplifying the generation
of multiple lines.}
\item{label}{A text string representing a symbolic label for the
table for referencing as an anchor. All you need to do is to reference the
table, for instance \verb{see table 2}. This is
known as the element's id attribute, i.e. table id, in HTML linguo, and should
be unique id for an HTML element in contrast to the \code{css.class} element attribute.}
\item{rgroup}{A vector of character strings containing headings for row groups.
\code{n.rgroup} must be present when \code{rgroup} is given. See
detailed description in section below.}
\item{n.rgroup}{An integer vector giving the number of rows in each grouping. If \code{rgroup}
is not specified, \code{n.rgroup} is just used to divide off blocks of rows by horizontal
lines. If \code{rgroup} is given but \code{n.rgroup} is omitted, \code{n.rgroup} will
default so that each row group contains the same number of rows. If you want additional
rgroup column elements to the cells you can sett the "add" attribute to \code{rgroup} through
\code{attr(rgroup, "add")}, see below explaining section.}
\item{cgroup}{A vector, matrix or list of character strings defining major column header. The default
is to have none. These elements are also known as \emph{column spanners}. If you want a column \emph{not}
to have a spanner then put that column as "". If you pass cgroup and \code{n.crgroup} as
matrices you can have column spanners for several rows. See cgroup section below for details.}
\item{n.cgroup}{An integer vector, matrix or list containing the number of columns for which each element in
cgroup is a heading. For example, specify \code{cgroup=c("Major_1","Major_2")},
\code{n.cgroup=c(3,3)} if \code{"Major_1"} is to span columns 1-3 and
\code{"Major_2"} is to span columns 4-6.
\code{rowlabel} does not count in the column numbers. You can omit \code{n.cgroup}
if all groups have the same number of columns. If the \code{n.cgroup} is one less than
the number of columns in the matrix/data.frame then it automatically adds those.}
\item{tspanner}{The table spanner is somewhat of a table header that
you can use when you want to join different tables with the same columns.}
\item{n.tspanner}{An integer vector with the number of rows or \code{rgroup}s in the original
matrix that the table spanner should span. If you have provided one fewer n.tspanner elements
the last will be imputed from the number of \code{rgroup}s (if you have provided \code{rgroup} and
\code{sum(n.tspanner) < length(rgroup)}) or the number of rows in the table.}
\item{total}{The last row is sometimes a row total with a border on top and
bold fonts. Set this to \code{TRUE} if you are interested in such a row. If you
want a total row at the end of each table spanner you can set this to \code{"tspanner"}.}
\item{ctable}{If the table should have a double top border or a single a' la LaTeX ctable style}
\item{compatibility}{Is default set to \code{LibreOffice} as some
settings need to be in old HTML format as Libre Office can't
handle some commands such as the css caption-alignment. Note: this
option is not yet fully implemented for all details, in the future
I aim to generate a HTML-correct table and one that is aimed
at Libre Office compatibility. Word-compatibility is difficult as
Word ignores most settings and destroys all layout attempts
(at least that is how my 2010 version behaves). You can additinally use the
\code{options(htmlTableCompat = "html")} if you want a change to apply
to the entire document.
MS Excel sometimes misinterprets certain cell data when opening HTML-tables (eg. 1/2 becomes 1. February).
To avoid this please specify the correct Microsoft Office format for each cell in the table using the css.cell-argument.
To make MS Excel interpret everything as text use "mso-number-format:\"\\@\"".}
\item{cspan.rgroup}{The number of columns that an \code{rgroup} should span. It spans
by default all columns but you may want to limit this if you have column colors
that you want to retain.}
\item{escape.html}{logical: should HTML characters be escaped? Defaults to FALSE.}
\item{...}{Passed on to \code{print.htmlTable} function and any argument except the
\code{useViewer} will be passed on to the \code{\link[base:cat]{base::cat()}} functions arguments.
\emph{Note:} as of version 2.0.0 styling options are still allowed but it is recommended
to instead preprocess your object with \code{\link[=addHtmlTableStyle]{addHtmlTableStyle()}}.}
\item{useViewer}{If you are using RStudio there is a viewer thar can render
the table within that is envoced if in \code{\link[base:interactive]{base::interactive()}} mode.
Set this to \code{FALSE} if you want to remove that functionality. You can
also force the function to call a specific viewer by setting this to a
viewer function, e.g. \code{useViewer = utils::browseURL} if you want to
override the default RStudio viewer. Another option that does the same is to
set the \code{options(viewer=utils::browseURL)} and it will default to that
particular viewer (this is how RStudio decides on a viewer).
\emph{Note:} If you want to force all output to go through the
\code{\link[base:cat]{base::cat()}} the set \verb{[options][base::options](htmlTable.cat = TRUE)}.}
}
\value{
Returns a formatted string representing an HTML table of class \code{htmlTable}.
}
\description{
Generates advanced HTML tables with column and row groups
for a dense representation of complex data. Designed for
maximum compatibility with copy-paste into word processors.
For styling, see \code{\link[=addHtmlTableStyle]{addHtmlTableStyle()}} and \code{\link[=setHtmlTableTheme]{setHtmlTableTheme()}}.
\emph{Note:} If you are using \pkg{tidyverse} and \pkg{dplyr} you may
want to check out \code{\link[=tidyHtmlTable]{tidyHtmlTable()}} that automates many of the arguments
that \code{htmlTable} requires.
}
\section{Multiple rows of column spanners \code{cgroup}}{
If you want to have a column spanner in multiple levels (rows) you can
set the \code{cgroup} and \code{n.cgroup} arguments to a \code{matrix} or \code{list}.
For different level elements, set absent ones to NA in a matrix. For example,
\code{cgroup = rbind(c("first", "second", NA), c("a", "b", "c"))}.
And the corresponding \code{n.cgroup} would be \code{n.cgroup = rbind(c(1, 2, NA), c(2, 1, 2))}.
for a table consisting of 5 columns. The "first" spans the first two columns,
the "second" spans the last three columns, "a" spans the first two, "b"
the middle column, and "c" the last two columns.
Using a list is recommended to avoid handling \code{NA}s.
For an empty \code{cgroup}, use \code{""}.
}
\section{The \code{rgroup} argument}{
The \code{rgroup} groups rows seamlessly. Each row in a group is indented by two
spaces (unless the rgroup is \code{""}) and grouped by its rgroup element. The \code{sum(n.rgroup)}
should be zr3ywKOjLZACY4j7TuGXu4v6I8wVWuKy-\eqn{\leq} matrix rows. If fewer, remaining rows are padded with an empty rgroup (\code{""}). If \code{rgroup}
has one more element than \code{n.rgroup}, the last \code{n.rgroup} is computed as \code{nrow(x) - sum(n.rgroup)}
for a smoother table generation.
}
\section{The add attribute to \code{rgroup}}{
To add an extra element at the \code{rgroup} level/row, use \code{attr(rgroup, 'add')}.
The value can either be a \code{vector}, a \code{list},
or a \code{matrix}. See \code{vignette("general", package = "htmlTable")} for examples.
\itemize{
\item A \code{vector} of either equal number of \code{rgroup}s to the number
of \code{rgroup}s that aren't empty, i.e. \code{rgroup[rgroup != ""]}. Or a named vector where
the name must correspond to either an \code{rgroup} or to an \code{rgroup} number.
\item A \code{list} that has exactly the same requirements as the vector.
In addition to the previous we can also have a list with column numbers within
as names within the list.
\item A \code{matrix} with the dimension \verb{nrow(x) x ncol(x)} or
\verb{nrow(x) x 1} where the latter is equivalent to a named vector.
If you have \code{rownames} these will resolve similarly to the names to the
\code{list}/\code{vector} arguments. The same thing applies to \code{colnames}.
}
}
\section{Important \pkg{knitr}-note}{
This function will only work with \pkg{knitr} outputting \emph{HTML}, i.e.
markdown mode. As the function returns raw HTML-code
the compatibility with non-HTML formatting is limited,
even with \href{https://pandoc.org/}{pandoc}.
Thanks to the the \code{\link[knitr:knit_print]{knitr::knit_print()}} and the \code{\link[knitr:asis_output]{knitr::asis_output()}}
the \code{results='asis'} is \emph{no longer needed} except within for-loops.
If you have a knitr-chunk with a for loop and use \code{print()} to produce
raw HTML you must set the chunk option \code{results='asis'}. \emph{Note}:
the print-function relies on the \code{\link[base:interactive]{base::interactive()}} function
for determining if the output should be sent to a browser or to the terminal.
In vignettes and other directly knitted documents you may need to either set
\code{useViewer = FALSE} alternatively set \code{options(htmlTable.cat = TRUE)}.
}
\section{RStudio's notebook}{
RStudio has an interactive notebook that allows output directly into the document.
In order for the output to be properly formatted it needs to have the \code{class}
of \code{html}. The \code{htmlTable} tries to identify if the environment is a
notebook document (uses the \pkg{rstudioapi} and identifies if its a file with and \code{Rmd}
file ending or if there is an element with \code{html_notebook}). If you don't want this
behavior you can remove it using the \code{options(htmlTable.skip_notebook = TRUE)}.
}
\section{Table counter}{
If you set the option table_counter you will get a Table 1,2,3
etc before each table, just set \code{options(table_counter=TRUE)}. If
you set it to a number then that number will correspond to the start of
the table_counter. The \code{table_counter} option will also contain the number
of the last table, this can be useful when referencing it in text. By
setting the option \code{options(table_counter_str = "Table \%s: ")}
you can manipulate the counter table text that is added prior to the
actual caption. Note, you should use the \code{\link[=sprintf]{sprintf()}} \verb{\%s}
instead of \verb{\%d} as the software converts all numbers to characters
for compatibility reasons. If you set \code{options(table_counter_roman = TRUE)}
then the table counter will use Roman numerals instead of Arabic.
}
\section{Empty data frames}{
An empty data frame will result in a warning and output an empty table, provided that
\code{rgroup} and \code{n.rgroup} are not specified. All other row layout options will be ignored.
}
\section{Options}{
There are multiple options that can be set, here is a set of the perhaps most used
\itemize{
\item \code{table_counter} - logical - activates a counter for each table
\item \code{table_counter_roman} - logical - if true the counter is in Roman numbers, i.e. I, II, III, IV...
\item \code{table_counter_str} - string - the string used for generating the table counter text
\item \code{useViewer} - logical - if viewer should be used fro printing the table
\item \code{htmlTable.cat} - logical - if the output should be directly sent to \code{cat()}
\item \code{htmlTable.skip_notebook} - logical - skips the logic for detecting notebook
\item \code{htmlTable.pretty_indentation} - logical - there was some issues in previous Pandoc versions
where HTML indentation caused everything to be interpreted as code. This seems to be fixed
and if you want to look at the raw HTML code it is nice to have this set to \code{TRUE} so that
the tags and elements are properly indented.
\item \code{htmlTableCompat} - string - see parameter description
}
}
\section{Other}{
\emph{Copy-pasting:} As you copy-paste results into Word you need to keep
the original formatting. Either right click and choose that paste option or click
on the icon appearing after a paste. Currently the following compatibilities
have been tested with MS Word 2016:
\itemize{
\item \strong{Internet Explorer} (v. 11.20.10586.0) Works perfectly when copy-pasting into Word
\item \strong{RStudio} (v. 0.99.448) Works perfectly when copy-pasting into Word.
\emph{Note:} can have issues with multi-line \code{cgroup}s -
see \href{https://bugs.chromium.org/p/chromium/issues/detail?id=305130}{bug}
\item \strong{Chrome} (v. 47.0.2526.106) Works perfectly when copy-pasting into Word.
\emph{Note:} can have issues with multi-line \code{cgroup}s -
see \href{https://bugs.chromium.org/p/chromium/issues/detail?id=305130}{bug}
\item \strong{Firefox} (v. 43.0.3) Works poorly - looses font-styling, lines and general feel
\item \strong{Edge} (v. 25.10586.0.0) Works poorly - looses lines and general feel
}
\emph{Direct word processor opening:} Opening directly in Libre Office or Word is no longer
recommended. You get much prettier results using the cut-and-paste option.
\emph{Google docs}: Copy-paste directly into a Google docs document is handled rather well. This
seems to work especially well when the paste comes directly from a Chrome browser.
\emph{Note} that when using complex \code{cgroup} alignments with multiple levels
not every browser is able to handle this. For instance the RStudio
webkit browser seems to have issues with this and a
\href{https://bugs.chromium.org/p/chromium/issues/detail?id=305130}{bug has been filed}.
As the table uses HTML for rendering you need to be aware of that headers,
row names, and cell values should try respect this for optimal display. Browsers
try to compensate and frequently the tables still turn out fine but it is
not advised. Most importantly you should try to use
\verb{<} instead of \code{<} and
\verb{>} instead of \code{>}. You can find a complete list
of HTML characters \href{https://ascii.cl/htmlcodes.htm}{here}.
Lastly, I want to mention that function was inspired by the \code{\link[Hmisc:latex]{Hmisc::latex()}}
that can be an excellent alternative if you wish to switch to PDF-output.
For the sibling function \code{\link[=tidyHtmlTable]{tidyHtmlTable()}} you can directly switch between
the two using the \code{table_fn} argument.
}
\examples{
library(magrittr)
# Basic example
output <- matrix(1:4,
ncol = 2,
dimnames = list(list("Row 1", "Row 2"),
list("Column 1", "Column 2")))
htmlTable(output)
invisible(readline(prompt = "Press [enter] to continue"))
# An advanced output
output <- matrix(ncol = 6, nrow = 8)
for (nr in 1:nrow(output)) {
for (nc in 1:ncol(output)) {
output[nr, nc] <-
paste0(nr, ":", nc)
}
}
output \%>\% addHtmlTableStyle(align = "r",
col.columns = c(rep("none", 2),
rep("#F5FBFF", 4)),
col.rgroup = c("none", "#F7F7F7"),
css.cell = "padding-left: .5em; padding-right: .2em;") \%>\%
htmlTable(header = paste(c("1st", "2nd",
"3rd", "4th",
"5th", "6th"),
"hdr"),
rnames = paste(c("1st", "2nd",
"3rd",
paste0(4:8, "th")),
"row"),
rgroup = paste("Group", LETTERS[1:3]),
n.rgroup = c(2,4,nrow(output) - 6),
cgroup = rbind(c("", "Column spanners", NA),
c("", "Cgroup 1", "Cgroup 2†")),
n.cgroup = rbind(c(1,2,NA),
c(2,2,2)),
caption = "Basic table with both column spanners (groups) and row groups",
tfoot = "† A table footer commment",
cspan.rgroup = 2)
invisible(readline(prompt = "Press [enter] to continue"))
# An advanced empty table
suppressWarnings({
matrix(ncol = 6,
nrow = 0) \%>\%
addHtmlTableStyle(col.columns = c(rep("none", 2),
rep("#F5FBFF", 4)),
col.rgroup = c("none", "#F7F7F7"),
css.cell = "padding-left: .5em; padding-right: .2em;") \%>\%
htmlTable(align = "r",
header = paste(c("1st", "2nd",
"3rd", "4th",
"5th", "6th"),
"hdr"),
cgroup = rbind(c("", "Column spanners", NA),
c("", "Cgroup 1", "Cgroup 2†")),
n.cgroup = rbind(c(1,2,NA),
c(2,2,2)),
caption = "Basic empty table with column spanners (groups) and ignored row colors",
tfoot = "† A table footer commment",
cspan.rgroup = 2)
})
invisible(readline(prompt = "Press [enter] to continue"))
# An example of how to use the css.cell for header styling
simple_output <- matrix(1:4, ncol = 2)
simple_output \%>\%
addHtmlTableStyle(css.cell = rbind(rep("background: lightgrey; font-size: 2em;",
times = ncol(simple_output)),
matrix("",
ncol = ncol(simple_output),
nrow = nrow(simple_output)))) \%>\%
htmlTable(header = LETTERS[1:2])
invisible(readline(prompt = "Press [enter] to continue"))
# See vignette("tables", package = "htmlTable")
# for more examples, also check out tidyHtmlTable() that manages
# the group arguments for you through tidy-select syntax
}
\seealso{
\code{\link[=addHtmlTableStyle]{addHtmlTableStyle()}},
\code{\link[=setHtmlTableTheme]{setHtmlTableTheme()}},
\code{\link[=tidyHtmlTable]{tidyHtmlTable()}}.
\code{\link[=txtMergeLines]{txtMergeLines()}},
\code{\link[Hmisc:latex]{Hmisc::latex()}}
Other table functions:
\code{\link{tblNoLast}()},
\code{\link{tblNoNext}()}
}
\concept{table functions}
htmlTable/man/prGetRowlabelPos.Rd 0000644 0001762 0000144 00000002600 13730316012 016455 0 ustar ligges users % Generated by roxygen2: do not edit by hand
% Please edit documentation in R/htmlTable_helpers_getRowlabelPos.R
\name{prGetRowlabelPos}
\alias{prGetRowlabelPos}
\title{Gets the rowlabel position}
\usage{
prGetRowlabelPos(cgroup = NULL, pos.rowlabel, header = NULL)
}
\arguments{
\item{cgroup}{A vector, matrix or list of character strings defining major column header. The default
is to have none. These elements are also known as \emph{column spanners}. If you want a column \emph{not}
to have a spanner then put that column as "". If you pass cgroup and \code{n.crgroup} as
matrices you can have column spanners for several rows. See cgroup section below for details.}
\item{header}{A vector of character strings specifying column
header, defaulting to \code{\link[base:colnames]{colnames(x)}}}
}
\value{
\code{integer} Returns the position within the header rows
to print the \code{rowlabel} argument
}
\description{
Gets the rowlabel position
}
\seealso{
Other hidden helper functions for htmlTable:
\code{\link{prAddCells}()},
\code{\link{prAddEmptySpacerCell}()},
\code{\link{prAddSemicolon2StrEnd}()},
\code{\link{prEscapeHtml}()},
\code{\link{prGetCgroupHeader}()},
\code{\link{prGetStyle}()},
\code{\link{prPrepInputMatrixDimensions}()},
\code{\link{prPrepareAlign}()},
\code{\link{prPrepareCgroup}()},
\code{\link{prTblNo}()}
}
\concept{hidden helper functions for htmlTable}
\keyword{internal}
htmlTable/man/pvalueFormatter.Rd 0000644 0001762 0000144 00000001013 13701421460 016401 0 ustar ligges users % Generated by roxygen2: do not edit by hand
% Please edit documentation in R/deprecated.R
\name{pvalueFormatter}
\alias{pvalueFormatter}
\title{Deprecated use \code{\link[=txtPval]{txtPval()}} instead}
\usage{
pvalueFormatter(...)
}
\arguments{
\item{...}{Currently only used for generating warnings of deprecated call}
}
\description{
Deprecated use \code{\link[=txtPval]{txtPval()}} instead
}
\examples{
\dontrun{
# Deprecated function
pvalueFormatter(c(0.10234,0.010234, 0.0010234, 0.000010234))
}
}
\keyword{internal}
htmlTable/man/innerJoinByCommonCols.Rd 0000644 0001762 0000144 00000000744 13701421460 017453 0 ustar ligges users % Generated by roxygen2: do not edit by hand
% Please edit documentation in R/tidyHtmlTable_helpers_innerJoinByCommonCols.r
\name{innerJoinByCommonCols}
\alias{innerJoinByCommonCols}
\title{A simple function for joining two tables by their
intersected columns}
\usage{
innerJoinByCommonCols(x, y)
}
\arguments{
\item{x}{\code{data.frame}}
\item{y}{\code{data.frame}}
}
\value{
\code{data.frame}
}
\description{
A simple function for joining two tables by their
intersected columns
}
htmlTable/man/getHtmlTableTheme.Rd 0000644 0001762 0000144 00000000754 13701421460 016573 0 ustar ligges users % Generated by roxygen2: do not edit by hand
% Please edit documentation in R/htmlTable_theme.R
\name{getHtmlTableTheme}
\alias{getHtmlTableTheme}
\title{Retrieve the \code{\link[=htmlTable]{htmlTable()}} theme list}
\usage{
getHtmlTableTheme()
}
\value{
\code{list} with the styles to be applied to the table
}
\description{
A wrapper for a \code{\link[base:options]{getOption("htmlTable.theme")()}} call that
returns the standard theme unless one is set.
}
\examples{
getHtmlTableTheme()
}
htmlTable/man/SCB.Rd 0000644 0001762 0000144 00000002744 14517434555 013663 0 ustar ligges users % Generated by roxygen2: do not edit by hand
% Please edit documentation in R/data-SCB.R
\docType{data}
\name{SCB}
\alias{SCB}
\title{Average age in Sweden}
\description{
For the vignettes there is a dataset downloaded by using the
\code{get_pxweb_data()} call. The data is from
SCB (\href{https://www.scb.se//}{Statistics Sweden}) and downloaded
using the \href{https://github.com/rOpenGov/pxweb}{pxweb package}:
}
\examples{
\dontrun{
# The data was generated through downloading via the API
library(pxweb)
# Get the last 15 years of data (the data always lags 1 year)
current_year <- as.integer(format(Sys.Date(), "\%Y")) -1
SCB <- get_pxweb_data(
url = "http://api.scb.se/OV0104/v1/doris/en/ssd/BE/BE0101/BE0101B/BefolkningMedelAlder",
dims = list(Region = c('00', '01', '03', '25'),
Kon = c('1', '2'),
ContentsCode = c('BE0101G9'),
Tid = (current_year-14):current_year),
clean = TRUE)
# Some cleaning was needed before use
SCB$region <- factor(substring(as.character(SCB$region), 4))
Swe_ltrs <- c("å" = "å",
"Å" = "Å",
"ä" = "ä",
"Ä" = "Ä",
"ö" = "ö",
"Ö" = "Ö")
for (i in 1:length(Swe_ltrs)){
levels(SCB$region) <- gsub(names(Swe_ltrs)[i],
Swe_ltrs[i],
levels(SCB$region))
}
save(SCB, file = "data/SCB.rda")
}
}
\references{
\url{https://www.scb.se/}
}
\author{
Max Gordon \email{max@gforge.se}
}
\keyword{data}
htmlTable/man/prConvertDfFactors.Rd 0000644 0001762 0000144 00000001104 13701421460 017000 0 ustar ligges users % Generated by roxygen2: do not edit by hand
% Please edit documentation in R/htmlTable_helpers_convertDfFactors.R
\name{prConvertDfFactors}
\alias{prConvertDfFactors}
\title{Convert all factors to characters to print them as they expected}
\usage{
prConvertDfFactors(x)
}
\arguments{
\item{x}{The matrix/data.frame with the data. For the \code{print} and \code{knit_print}
it takes a string of the class \code{htmlTable} as \code{x} argument.}
}
\value{
The data frame with factors as characters
}
\description{
Convert all factors to characters to print them as they expected
}
htmlTable/man/prExtractElementsAndConvertToTbl.Rd 0000644 0001762 0000144 00000001047 13701421460 021632 0 ustar ligges users % Generated by roxygen2: do not edit by hand
% Please edit documentation in
% R/tidyHtmlTable_helpers_extractElementsAndConvertToTbl.R
\name{prExtractElementsAndConvertToTbl}
\alias{prExtractElementsAndConvertToTbl}
\title{Extract the elements and generate a table with unique elements}
\usage{
prExtractElementsAndConvertToTbl(x, elements)
}
\arguments{
\item{x}{\code{list} with columns to be joined}
\item{elements}{\code{char} vector with the elements to select}
}
\description{
Extract the elements and generate a table with unique elements
}
htmlTable/man/prAddEmptySpacerCell.Rd 0000644 0001762 0000144 00000002553 13730316012 017240 0 ustar ligges users % Generated by roxygen2: do not edit by hand
% Please edit documentation in R/htmlTable_render_prAddEmptySpacerCell.R
\name{prAddEmptySpacerCell}
\alias{prAddEmptySpacerCell}
\title{Add an empty cell}
\usage{
prAddEmptySpacerCell(
x,
style_list,
cell_style,
align_style,
cell_tag = c("td", "th"),
colspan = 1
)
}
\arguments{
\item{x}{The matrix/data.frame with the data. For the \code{print} and \code{knit_print}
it takes a string of the class \code{htmlTable} as \code{x} argument.}
\item{cell_style}{The style of the current cell that should be applied to all cells}
\item{align_style}{The style from \code{\link[=prGetAlign]{prGetAlign()}}}
\item{cell_tag}{What HTML tag to use}
\item{colspan}{The number of rows each tag should span}
}
\value{
\code{string}
}
\description{
Depending on the \code{spacer.celltype} set in \code{\link[=addHtmlTableStyle]{addHtmlTableStyle()}} we
will use different spacer cells.
}
\seealso{
Other hidden helper functions for htmlTable:
\code{\link{prAddCells}()},
\code{\link{prAddSemicolon2StrEnd}()},
\code{\link{prEscapeHtml}()},
\code{\link{prGetCgroupHeader}()},
\code{\link{prGetRowlabelPos}()},
\code{\link{prGetStyle}()},
\code{\link{prPrepInputMatrixDimensions}()},
\code{\link{prPrepareAlign}()},
\code{\link{prPrepareCgroup}()},
\code{\link{prTblNo}()}
}
\concept{hidden helper functions for htmlTable}
\keyword{internal}
htmlTable/man/prPrepInputMatrixDimensions.Rd 0000644 0001762 0000144 00000002213 13730316012 020730 0 ustar ligges users % Generated by roxygen2: do not edit by hand
% Please edit documentation in R/htmlTable_helpers_prepInputMatrixDimensions.R
\name{prPrepInputMatrixDimensions}
\alias{prPrepInputMatrixDimensions}
\title{Makes sure the input is correct}
\usage{
prPrepInputMatrixDimensions(x, header = NULL)
}
\arguments{
\item{x}{The matrix/data.frame with the data. For the \code{print} and \code{knit_print}
it takes a string of the class \code{htmlTable} as \code{x} argument.}
\item{header}{A vector of character strings specifying column
header, defaulting to \code{\link[base:colnames]{colnames(x)}}}
}
\description{
Checks and converts dimensions into something the
\code{\link[=htmlTable]{htmlTable()}} is comfortable with.
}
\seealso{
Other hidden helper functions for htmlTable:
\code{\link{prAddCells}()},
\code{\link{prAddEmptySpacerCell}()},
\code{\link{prAddSemicolon2StrEnd}()},
\code{\link{prEscapeHtml}()},
\code{\link{prGetCgroupHeader}()},
\code{\link{prGetRowlabelPos}()},
\code{\link{prGetStyle}()},
\code{\link{prPrepareAlign}()},
\code{\link{prPrepareCgroup}()},
\code{\link{prTblNo}()}
}
\concept{hidden helper functions for htmlTable}
\keyword{internal}
htmlTable/man/vector2string.Rd 0000644 0001762 0000144 00000001320 13701421460 016035 0 ustar ligges users % Generated by roxygen2: do not edit by hand
% Please edit documentation in R/vector2string.R
\name{vector2string}
\alias{vector2string}
\title{Collapse vector to string}
\usage{
vector2string(
x,
quotation_mark = "'",
collapse = sprintf("\%s, \%s", quotation_mark, quotation_mark)
)
}
\arguments{
\item{x}{The vector to collapse}
\item{quotation_mark}{The type of quote to use}
\item{collapse}{The string that separates each element}
}
\value{
A string with \code{', '} separation
}
\description{
Merges all the values and outputs a string
formatted as '1st element', '2nd element', ...
}
\examples{
vector2string(1:4)
vector2string(c("a", "b'b", "c"))
vector2string(c("a", "b'b", "c"), quotation_mark = '"')
}
htmlTable/man/prGetStyle.Rd 0000644 0001762 0000144 00000002152 14517434555 015347 0 ustar ligges users % Generated by roxygen2: do not edit by hand
% Please edit documentation in R/htmlTable_helpers_getStyle.R
\name{prGetStyle}
\alias{prGetStyle}
\title{Gets the CSS style element}
\usage{
prGetStyle(...)
}
\arguments{
\item{...}{Styles can be provided as \code{vector}, \verb{named vector}, or \code{string}.
If you provide a name, e.g. \code{background: blue}, \code{align="center"},
the function will convert the \code{align} into proper \code{align: center}.}
}
\value{
\code{string} Returns the codes merged into one string with
correct CSS ; and : structure.
}
\description{
A function for checking, merging, and more
with a variety of different style formats.
}
\seealso{
Other hidden helper functions for htmlTable:
\code{\link{prAddCells}()},
\code{\link{prAddEmptySpacerCell}()},
\code{\link{prAddSemicolon2StrEnd}()},
\code{\link{prEscapeHtml}()},
\code{\link{prGetCgroupHeader}()},
\code{\link{prGetRowlabelPos}()},
\code{\link{prPrepInputMatrixDimensions}()},
\code{\link{prPrepareAlign}()},
\code{\link{prPrepareCgroup}()},
\code{\link{prTblNo}()}
}
\concept{hidden helper functions for htmlTable}
\keyword{internal}
htmlTable/man/outputInt.Rd 0000644 0001762 0000144 00000000670 13701421460 015244 0 ustar ligges users % Generated by roxygen2: do not edit by hand
% Please edit documentation in R/deprecated.R
\name{outputInt}
\alias{outputInt}
\title{Deprecated use \code{\link[=txtInt]{txtInt()}} instead.}
\usage{
outputInt(...)
}
\arguments{
\item{...}{Passed to \code{\link[=txtInt]{txtInt()}}}
}
\description{
Deprecated use \code{\link[=txtInt]{txtInt()}} instead.
}
\examples{
\dontrun{
# Deprecated function
outputInt(123456)
}
}
\keyword{internal}
htmlTable/man/setHtmlTableTheme.Rd 0000644 0001762 0000144 00000015315 13730316012 016604 0 ustar ligges users % Generated by roxygen2: do not edit by hand
% Please edit documentation in R/htmlTable_theme.R
\name{setHtmlTableTheme}
\alias{setHtmlTableTheme}
\title{Set or update theme for \code{\link[=htmlTable]{htmlTable()}}}
\usage{
setHtmlTableTheme(
theme = NULL,
align = NULL,
align.header = NULL,
align.cgroup = NULL,
css.rgroup = NULL,
css.rgroup.sep = NULL,
css.tspanner = NULL,
css.tspanner.sep = NULL,
css.total = NULL,
css.cell = NULL,
css.cgroup = NULL,
css.header = NULL,
css.header.border_bottom = NULL,
css.class = NULL,
css.table = NULL,
pos.rowlabel = NULL,
pos.caption = NULL,
col.rgroup = NULL,
col.columns = NULL,
padding.rgroup = NULL,
padding.tspanner = NULL,
spacer.celltype = NULL,
spacer.css.cgroup.bottom.border = NULL,
spacer.css = NULL,
spacer.content = NULL
)
}
\arguments{
\item{theme}{A \code{list} containing all the styles or a \code{string} that is matched to some of the preset style (See details
below in the \emph{Theme options} section). \emph{Note}: the full name of the theme is not required as they are matched
using \code{\link[base:match.arg]{base::match.arg()}}.}
\item{align}{A character strings specifying column alignments, defaulting to \code{'c'}
to center. Valid chars for alignments are l = left, c = center and r = right. You can also specify
\code{align='c|c'} and other LaTeX tabular formatting. If you want to set the alignment of the
rownames this string needst to be \code{ncol(x) + 1}, otherwise it automatically
pads the string with a left alignment for the rownames.}
\item{align.header}{A character strings specifying alignment for column header,
defaulting to centered, i.e. \verb{[paste][base::paste](rep('c',ncol(x)),collapse='')}.}
\item{align.cgroup}{The justification of the \code{cgroups}}
\item{css.rgroup}{CSS style for the rgroup, if different styles are wanted for each of the
rgroups you can just specify a vector with the number of elements.}
\item{css.rgroup.sep}{The line between different rgroups. The line is set to the TR element
of the lower rgroup, i.e. you have to set the border-top/padding-top etc to a line with
the expected function. This is only used for rgroups that are printed. You can specify
different separators if you give a vector of rgroup - 1 length (this is since the first
rgroup doesn't have a separator).}
\item{css.tspanner}{The CSS style for the table spanner.}
\item{css.tspanner.sep}{The line between different spanners.}
\item{css.total}{The css of the total row if such is activated.}
\item{css.cell}{The css.cell element allows you to add any possible CSS style to your
table cells. See section below for details.}
\item{css.cgroup}{The same as \code{css.class} but for cgroup formatting.}
\item{css.header}{The header style, not including the cgroup style}
\item{css.header.border_bottom}{The header bottom-border style, e.g. \verb{border-bottom: 1px solid grey}}
\item{css.class}{The html CSS class for the table. This allows directing html
formatting through \href{https://www.w3schools.com/Css/}{CSS}
directly at all instances of that class. \emph{Note:} unfortunately the
CSS is frequently ignored by word processors. This option
is mostly inteded for web-presentations.}
\item{css.table}{You can specify the the style of the table-element using this parameter}
\item{pos.rowlabel}{Where the rowlabel should be positioned. This value can be \code{"top"},
\code{"bottom"}, \code{"header"}, or a integer between \code{1} and \code{nrow(cgroup) + 1}. The options
\code{"bottom"} and \code{"header"} are the same, where the row label is presented at the same level as
the header.}
\item{pos.caption}{Set to \code{"bottom"} to position a caption below the table
instead of the default of \code{"top"}.}
\item{col.rgroup}{Alternating colors (zebra striping/banded rows) for each \code{rgroup}; one or two colors
is recommended and will be recycled.}
\item{col.columns}{Alternating colors for each column.}
\item{padding.rgroup}{Generally two non-breakings spaces, i.e. \verb{ }, but some
journals only have a bold face for the rgroup and leaves the subelements unindented.}
\item{padding.tspanner}{The table spanner is usually without padding but you may specify padding
similar to \code{padding.rgroup} and it will be added to all elements, including the rgroup elements.
This allows for a 3-level hierarchy if needed.}
\item{spacer.celltype}{When using cgroup the table headers are separated through a empty
HTML cell that is by default filled with \verb{ } (no-breaking-space) that prevents the cell
from collapsing. The purpose of this is to prevent the headers underline to bleed into one
as the underline is for the entire cell. You can alter this behavior by changing this option,
valid options are \code{single_empty}, \code{skip}, \code{double_cell}. The \code{single_empty} is the default,
the \code{skip} lets the header bleed into one and skips entirely, \code{double_cell} is for having
two cells so that a vertical border ends up centered (specified using the \code{align} option).
The arguments are matched internally using \link[base:match.arg]{base::match.arg} so you can specify only a part
of the name, e.g. \code{"sk"} will match \code{"skip"}.}
\item{spacer.css.cgroup.bottom.border}{Defaults to \code{none} and used for separating cgroup headers.
Due to a browser bug this is sometimes ignored and you may therefore need to set this
to \verb{1px solid white} to enforce a white border.}
\item{spacer.css}{If you want the spacer cells to share settings you can set it here}
\item{spacer.content}{Defaults to \verb{ } as this guarantees that the cell is not collapsed
and is highly compatible when copy-pasting to word processors.}
}
\value{
An invisible \code{list} with the new theme
}
\description{
The theme guides many of the non-data objects visual appearance. The
theme can be over-ridden by settings for each table. Too get a more complete
understanding of the options, see \code{\link[=addHtmlTableStyle]{addHtmlTableStyle()}}.
}
\section{Theme options}{
The styles available are:
\itemize{
\item \code{standard}: The traditional standard style used in \code{\link[=htmlTable]{htmlTable()}} since the early days
\item \verb{Google docs}: A style that is optimized for copy-pasting into documents on Google drive. This
is geared towards minimal padding and margins so that the table is as dense as possible.
\item \code{blank}: Just as the name suggests the style is completly empty in terms of CSS. Positions
for rowlabel and caption are set to \code{bottom} as these cannot be blank.
}
You can also provide your own style. Each style should be a names vector, e.g. \code{c(width = "100px", color = "red")}
or just a real css string, \verb{width: 100px; color: red;}.
}
\examples{
\dontrun{
setHtmlTableTheme("Google", align = "r")
}
}
htmlTable/man/prepGroupCounts.Rd 0000644 0001762 0000144 00000001030 13701421460 016377 0 ustar ligges users % Generated by roxygen2: do not edit by hand
% Please edit documentation in R/prepGroupCounts.R
\name{prepGroupCounts}
\alias{prepGroupCounts}
\title{Retrieves counts for rgroup, cgroup, & tspanner arguments}
\usage{
prepGroupCounts(x)
}
\arguments{
\item{x}{The vector to process}
}
\value{
\code{list(n = rle$lengths, names = rle$values)}
}
\description{
This function is a wrapper to \code{\link[base:rle]{base::rle()}} that
does exactly this but is a little too picky about input values.
}
\examples{
prepGroupCounts(c(1:3, 3:1))
}
htmlTable/man/prGetRgroupLine.Rd 0000644 0001762 0000144 00000003423 13701421460 016320 0 ustar ligges users % Generated by roxygen2: do not edit by hand
% Please edit documentation in R/htmlTable_render_getRgroupLine.R
\name{prGetRgroupLine}
\alias{prGetRgroupLine}
\title{Gets the number of \code{rgroup} HTML line}
\usage{
prGetRgroupLine(
x,
total_columns = NULL,
rgroup = NULL,
rgroup_iterator = NULL,
cspan = NULL,
rnames = NULL,
style = NULL,
cgroup_spacer_cells = NULL,
style_list = NULL,
prepped_row_css = NULL
)
}
\arguments{
\item{x}{The matrix/data.frame with the data. For the \code{print} and \code{knit_print}
it takes a string of the class \code{htmlTable} as \code{x} argument.}
\item{total_columns}{The total number of columns including the \code{rowlabel} and the
spacer cells}
\item{rgroup}{A vector of character strings containing headings for row groups.
\code{n.rgroup} must be present when \code{rgroup} is given. See
detailed description in section below.}
\item{rgroup_iterator}{An integer indicating the \code{rgroup}}
\item{cspan}{The column span of the current \code{rgroup}}
\item{rnames}{Default row names are generated from \code{\link[base:colnames]{rownames(x)}}. If you
provide \code{FALSE} then it will skip the row names. \emph{Note:} For \code{data.frames}
if you do \code{\link[base:colnames]{rownames(my_dataframe) <- NULL}} it still has
row names. Thus you need to use \code{FALSE} if you want to
supress row names for \code{data.frames}.}
\item{style}{The css style corresponding to the \code{rgroup} css style that includes
the color specific for the \code{rgroup}, i.e. \code{col.rgroup}.}
\item{cgroup_spacer_cells}{The vector indicating the position of the \code{cgroup}
spacer cells}
\item{prepped_row_css}{The \code{css.cell} information for this particular row.}
}
\description{
Gets the number of \code{rgroup} HTML line
}
\keyword{internal}
htmlTable/man/splitLines4Table.Rd 0000644 0001762 0000144 00000000741 13701421460 016412 0 ustar ligges users % Generated by roxygen2: do not edit by hand
% Please edit documentation in R/deprecated.R
\name{splitLines4Table}
\alias{splitLines4Table}
\title{See \code{\link[=txtMergeLines]{txtMergeLines()}}}
\usage{
splitLines4Table(...)
}
\arguments{
\item{...}{passed onto \code{\link[=txtMergeLines]{txtMergeLines()}}}
}
\description{
See \code{\link[=txtMergeLines]{txtMergeLines()}}
}
\examples{
\dontrun{
# Deprecated function
splitLines4Table("hello", "world")
}
}
\keyword{internal}
htmlTable/man/concatHtmlTables.Rd 0000644 0001762 0000144 00000004372 14165130172 016465 0 ustar ligges users % Generated by roxygen2: do not edit by hand
% Please edit documentation in R/concatHtmlTables.R
\name{concatHtmlTables}
\alias{concatHtmlTables}
\title{Function for concatenating \code{\link[=htmlTable]{htmlTable()}}s}
\usage{
concatHtmlTables(tables, headers = NULL)
}
\arguments{
\item{tables}{A list of \code{\link[=htmlTable]{htmlTable()}}s to be concatenated}
\item{headers}{Either a string or a vector of strings that function as
a header for each table. If none is provided it will use the names of
the table list or a numeric number.}
}
\value{
\code{\link[=htmlTable]{htmlTable()}} class object
}
\description{
Function for concatenating \code{\link[=htmlTable]{htmlTable()}}s
}
\examples{
library(magrittr)
# Basic example
tables <- list()
output <- matrix(1:4,
ncol = 2,
dimnames = list(list("Row 1", "Row 2"),
list("Column 1", "Column 2")))
tables[["Simple table"]] <- htmlTable(output)
# An advanced output
output <- matrix(ncol = 6, nrow = 8)
for (nr in 1:nrow(output)) {
for (nc in 1:ncol(output)) {
output[nr, nc] <-
paste0(nr, ":", nc)
}
}
tables[["Fancy table"]] <- output \%>\%
addHtmlTableStyle(align = "r",
col.columns = c(rep("none", 2),
rep("#F5FBFF", 4)),
col.rgroup = c("none", "#F7F7F7"),
css.cell = "padding-left: .5em; padding-right: .2em;") \%>\%
htmlTable(header = paste(c("1st", "2nd",
"3rd", "4th",
"5th", "6th"),
"hdr"),
rnames = paste(c("1st", "2nd",
"3rd",
paste0(4:8, "th")),
"row"),
rgroup = paste("Group", LETTERS[1:3]),
n.rgroup = c(2,4,nrow(output) - 6),
cgroup = rbind(c("", "Column spanners", NA),
c("", "Cgroup 1", "Cgroup 2†")),
n.cgroup = rbind(c(1,2,NA),
c(2,2,2)),
caption = "Basic table with both column spanners (groups) and row groups",
tfoot = "† A table footer commment",
cspan.rgroup = 2)
concatHtmlTables(tables)
}
htmlTable/man/tidyHtmlTable.Rd 0000644 0001762 0000144 00000014206 14517463044 016011 0 ustar ligges users % Generated by roxygen2: do not edit by hand
% Please edit documentation in R/tidyHtmlTable.R
\name{tidyHtmlTable}
\alias{tidyHtmlTable}
\title{Generate an htmlTable using tidy data as input}
\usage{
tidyHtmlTable(
x,
value,
header,
rnames,
rgroup,
hidden_rgroup,
cgroup,
tspanner,
hidden_tspanner,
skip_removal_warning = getOption("htmlTable.skip_removal_warning", FALSE),
rnames_unique,
table_fn = htmlTable,
...
)
}
\arguments{
\item{x}{Tidy data used to build the \code{htmlTable}}
\item{value}{Column containing values for individual table cells. Defaults to "value" (same as \link[tidyr:pivot_wider]{tidyr::pivot_wider}).}
\item{header}{Column in \code{x} specifying column headings}
\item{rnames}{Column in \code{x} specifying row names. Defaults to "name" (same as \code{\link[tidyr:pivot_wider]{tidyr::pivot_wider()}}).}
\item{rgroup}{Column in \code{x} specifying row groups.}
\item{hidden_rgroup}{Strings indicating \code{rgroup} values to be hidden.}
\item{cgroup}{Columns in \code{x} specifying the column groups.}
\item{tspanner}{Column in \code{x} specifying \code{tspanner} groups.}
\item{hidden_tspanner}{Strings indicating \code{tspanner} values to be hidden.}
\item{skip_removal_warning}{Boolean to suppress warnings when removing \code{NA} columns.}
\item{rnames_unique}{Designates unique row names when regular names lack uniqueness.}
\item{table_fn}{Function to format the table, defaults to \code{\link[=htmlTable]{htmlTable()}}.}
\item{...}{Additional arguments passed to \code{\link[=htmlTable]{htmlTable()}}.}
}
\value{
Returns the HTML code that, when rendered, displays a formatted table.
}
\description{
This function maps columns from the input data, \code{x}, to \code{\link[=htmlTable]{htmlTable()}} parameters.
It's designed to provide a fluent interface for those familiar with the \code{tidyverse} ecosystem.
}
\section{Column-mapping}{
Columns from \code{x} are mapped (transformed) to specific parameters of the \code{\link[=htmlTable]{htmlTable()}}
The following columns are converted to match the intended input structure:
\itemize{
\item \code{value}
\item \code{header}
\item \code{rnames}
\item \code{rgroup}
\item \code{cgroup}
\item \code{tspanner}
}
Each combination of the variables in \code{x} should be unique to map correctly to the output table.
}
\section{Row uniqueness}{
Usually each row should have a unique combination of the mappers.
Sometimes though rows come in a distinct order and the order identifies
the row more than the name. E.g. if we are identifying bone fractures using the
AO-classification we will have classes ranging in the form of:
\itemize{
\item A
\item A1
\item A1.1
\item A2
\item A2.1
\item A2.2
\item B
\item ...
}
we can simplify the names while retaining the key knowledge to:
\itemize{
\item A
\item .1
\item ...1
\item .2
\item ...1
\item ...2
\item B
\item ...
}
This will though result in non-unique rows and thus we need to provide the original
names in addition to the \code{rnames} argument. To do this we have \code{rnames_unique} as a parameter,
without this \code{tidyHtmlTable} we risk unintended merging of cells, generating > 1 value per cell.
\emph{Note} it is recommended that you verify with the full names just to make sure that
any unexpected row order change has happened in the underlying pivot functions.
}
\section{Sorting}{
Rows can be pre-sorted using \code{\link[dplyr:arrange]{dplyr::arrange()}} before passing to \code{tidyHtmlTable}.
Column sorting is based on \code{arrange(cgroup, header)}. If you want to sort in non-alphabetic
order you can provide a factor variable and that information will be retained.
}
\section{Hidden values}{
\code{htmlTable} Allows for some values within \code{rgroup},
\code{cgroup}, etc. to be specified as \code{""}. The following parameters
allow for specific values to be treated as if they were a string of length
zero in the \code{htmlTable} function.
\itemize{
\item \code{hidden_rgroup}
\item \code{hidden_tspanner}
}
}
\section{Simple tibble output}{
The tibble discourages the use of row names. There is therefore a convenience
option for \code{tidyHtmlTable} where you can use the function just as you
would with \code{\link[=htmlTable]{htmlTable()}} where \code{rnames} is populated with
the \code{rnames} argument provided using \code{tidyselect} syntax (defaults to
the "names" column if present int the input data).
}
\section{Additional dependencies}{
In order to run this function you also must have \pkg{dplyr},
\pkg{tidyr}, \pkg{tidyselect} and \pkg{purrr}
packages installed. These have been removed due to
the additional 20 Mb that these dependencies added (issue #47).
\emph{Note:} if you use \pkg{tidyverse} it will already have
all of these and you do not need to worry.
}
\examples{
library(tibble)
library(dplyr)
library(tidyr)
# Prep and select basic data
data("mtcars")
base_data <- mtcars \%>\%
rownames_to_column() \%>\%
mutate(gear = paste(gear, "Gears"),
cyl = paste(cyl, "Cylinders")) \%>\%
select(rowname, cyl, gear, wt, mpg, qsec)
base_data \%>\%
pivot_longer(names_to = "per_metric",
cols = c(wt, mpg, qsec)) \%>\%
group_by(cyl, gear, per_metric) \%>\%
summarise(value_Mean = round(mean(value), 1),
value_Min = round(min(value), 1),
value_Max = round(max(value), 1),
.groups = "drop") \%>\%
pivot_wider(names_from = per_metric,
values_from = starts_with("value_")) \%>\%
# Round the values into a nicer format where we want the weights to have two decimals
txtRound(ends_with("_wt"), digits = 2) \%>\%
txtRound(starts_with("value") & !ends_with("_wt"), digits = 1) \%>\%
# Convert into long format
pivot_longer(cols = starts_with("value_"), names_prefix = "value_") \%>\%
separate(name, into = c("summary_stat", "per_metric")) \%>\%
# Without sorting the row groups wont appear right
# If the columns end up in the wrong order you may want to change the columns
# into factors
arrange(per_metric) \%>\%
addHtmlTableStyle(align = "r") \%>\%
tidyHtmlTable(
header = gear,
cgroup = cyl,
rnames = summary_stat,
rgroup = per_metric,
skip_removal_warning = TRUE)
}
\seealso{
\code{\link[=htmlTable]{htmlTable()}}
}
htmlTable/man/prGetScriptString.Rd 0000644 0001762 0000144 00000000671 13407215301 016665 0 ustar ligges users % Generated by roxygen2: do not edit by hand
% Please edit documentation in R/interactiveTable.R
\name{prGetScriptString}
\alias{prGetScriptString}
\title{Gets a string with all the scripts merged into one script tag}
\usage{
prGetScriptString(x)
}
\arguments{
\item{x}{An interactiveTable}
}
\value{
string
}
\description{
Each element has it's own script tags in otherwise an error will cause
all the scripts to fail.
}
\keyword{internal}
htmlTable/man/interactiveTable.Rd 0000644 0001762 0000144 00000006176 14517434555 016544 0 ustar ligges users % Generated by roxygen2: do not edit by hand
% Please edit documentation in R/interactiveTable.R
\name{interactiveTable}
\alias{interactiveTable}
\alias{interactiveTable.htmlTable}
\alias{knit_print.interactiveTable}
\alias{print.interactiveTable}
\title{An interactive table that allows you to limit the size of boxes}
\usage{
interactiveTable(
x,
...,
txt.maxlen = 20,
button = getOption("htmlTable.interactiveTable.button", default = FALSE),
minimized.columns = NULL,
js.scripts = c()
)
\method{interactiveTable}{htmlTable}(
x,
...,
txt.maxlen = 20,
button = getOption("htmlTable.interactiveTable.button", default = FALSE),
minimized.columns = NULL,
js.scripts = c()
)
\method{knit_print}{interactiveTable}(x, ...)
\method{print}{interactiveTable}(x, useViewer, ...)
}
\arguments{
\item{x}{The table to be printed}
\item{...}{The exact same parameters as \code{\link[=htmlTable]{htmlTable()}} uses}
\item{txt.maxlen}{The maximum length of a text}
\item{button}{Indicator if the cell should be clickable or if a button should appear with a plus/minus}
\item{minimized.columns}{Notifies if any particular columns should be collapsed from start}
\item{js.scripts}{If you want to add your own JavaScript code you can just add it here.
All code is merged into one string where each section is wrapped in it's own
\verb{} element.}
\item{useViewer}{If you are using RStudio there is a viewer thar can render
the table within that is envoced if in \code{\link[base:interactive]{base::interactive()}} mode.
Set this to \code{FALSE} if you want to remove that functionality. You can
also force the function to call a specific viewer by setting this to a
viewer function, e.g. \code{useViewer = utils::browseURL} if you want to
override the default RStudio viewer. Another option that does the same is to
set the \code{options(viewer=utils::browseURL)} and it will default to that
particular viewer (this is how RStudio decides on a viewer).
\emph{Note:} If you want to force all output to go through the
\code{\link[base:cat]{base::cat()}} the set \verb{[options][base::options](htmlTable.cat = TRUE)}.}
}
\value{
An htmlTable with a javascript attribute containing the code that is then printed
}
\description{
This function wraps the htmlTable and adds JavaScript code for toggling the amount
of text shown in any particular cell.
}
\examples{
library(magrittr)
# A simple output
long_txt <- "Lorem ipsum dolor sit amet, consectetur adipiscing elit,
sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.
Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi
ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit
in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur
sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt
mollit anim id est laborum"
short_txt <- gsub("(^[^.]+).*", "\\\\1", long_txt)
cbind(rep(short_txt, 2),
rep(long_txt, 2)) \%>\%
addHtmlTableStyle(col.rgroup = c("#FFF", "#EEF")) \%>\%
interactiveTable(minimized.columns = ncol(.),
header = c("Short", "Long"),
rnames = c("First", "Second"))
}
htmlTable/man/prSkipRownames.Rd 0000644 0001762 0000144 00000001336 13701421460 016215 0 ustar ligges users % Generated by roxygen2: do not edit by hand
% Please edit documentation in R/htmlTable_helpers_skipRownames.R
\name{prSkipRownames}
\alias{prSkipRownames}
\title{Returns if rownames should be printed for the htmlTable}
\usage{
prSkipRownames(rnames)
}
\arguments{
\item{rnames}{Default row names are generated from \code{\link[base:colnames]{rownames(x)}}. If you
provide \code{FALSE} then it will skip the row names. \emph{Note:} For \code{data.frames}
if you do \code{\link[base:colnames]{rownames(my_dataframe) <- NULL}} it still has
row names. Thus you need to use \code{FALSE} if you want to
supress row names for \code{data.frames}.}
}
\description{
Returns if rownames should be printed for the htmlTable
}
\keyword{internal}
htmlTable/man/prAddCells.Rd 0000644 0001762 0000144 00000003036 13730316012 015243 0 ustar ligges users % Generated by roxygen2: do not edit by hand
% Please edit documentation in R/htmlTable_render_addCells.R
\name{prAddCells}
\alias{prAddCells}
\title{Add a cell}
\usage{
prAddCells(
rowcells,
cellcode,
style_list,
style,
prepped_cell_css,
cgroup_spacer_cells,
has_rn_col,
offset = 1,
style_list_align_key = "align"
)
}
\arguments{
\item{rowcells}{The cells with the values that are to be added}
\item{cellcode}{Type of cell, can either be \code{th} or \code{td}}
\item{style_list}{The style_list}
\item{style}{The cell style}
\item{cgroup_spacer_cells}{The number of cells that occur between
columns due to the cgroup arguments.}
\item{has_rn_col}{Due to the alignment issue we need to keep track
of if there has already been printed a rowname column or not and therefore
we have this has_rn_col that is either 0 or 1.}
\item{offset}{For rgroup rows there may be an offset != 1}
}
\value{
\code{string} Returns the string with the new cell elements
}
\description{
Adds a row of cells \verb{val | ... | } to a table string for
\code{\link[=htmlTable]{htmlTable()}}
}
\seealso{
Other hidden helper functions for htmlTable:
\code{\link{prAddEmptySpacerCell}()},
\code{\link{prAddSemicolon2StrEnd}()},
\code{\link{prEscapeHtml}()},
\code{\link{prGetCgroupHeader}()},
\code{\link{prGetRowlabelPos}()},
\code{\link{prGetStyle}()},
\code{\link{prPrepInputMatrixDimensions}()},
\code{\link{prPrepareAlign}()},
\code{\link{prPrepareCgroup}()},
\code{\link{prTblNo}()}
}
\concept{hidden helper functions for htmlTable}
\keyword{internal}
htmlTable/man/prPrepareCss.Rd 0000644 0001762 0000144 00000002244 13701421460 015641 0 ustar ligges users % Generated by roxygen2: do not edit by hand
% Please edit documentation in R/htmlTable_helpers_prepareCss.R
\name{prPrepareCss}
\alias{prPrepareCss}
\title{Prepares the cell style}
\usage{
prPrepareCss(
x,
css,
rnames,
header = NULL,
name = deparse(substitute(css)),
style_list = NULL
)
}
\arguments{
\item{x}{The matrix/data.frame with the data. For the \code{print} and \code{knit_print}
it takes a string of the class \code{htmlTable} as \code{x} argument.}
\item{css}{The CSS styles that are to be converted into
a matrix.}
\item{rnames}{Default row names are generated from \code{\link[base:colnames]{rownames(x)}}. If you
provide \code{FALSE} then it will skip the row names. \emph{Note:} For \code{data.frames}
if you do \code{\link[base:colnames]{rownames(my_dataframe) <- NULL}} it still has
row names. Thus you need to use \code{FALSE} if you want to
supress row names for \code{data.frames}.}
\item{header}{A vector of character strings specifying column
header, defaulting to \code{\link[base:colnames]{colnames(x)}}}
\item{name}{The name of the CSS style that is prepared}
}
\value{
\code{matrix}
}
\description{
Prepares the cell style
}
\keyword{internal}
htmlTable/man/txtInt.Rd 0000644 0001762 0000144 00000002261 14165130172 014523 0 ustar ligges users % Generated by roxygen2: do not edit by hand
% Please edit documentation in R/txtFrmt.R
\name{txtInt}
\alias{txtInt}
\title{SI or English formatting of an integer}
\usage{
txtInt(
x,
language = getOption("htmlTable.language", default = "en"),
html = getOption("htmlTable.html", default = TRUE),
...
)
}
\arguments{
\item{x}{The integer variable}
\item{language}{The ISO-639-1 two-letter code for the language of
interest. Currently only English is distinguished from the ISO
format using a ',' as the separator.}
\item{html}{If the format is used in HTML context
then the space should be a non-breaking space, \verb{ }}
\item{...}{Passed to \code{\link[base:format]{base::format()}}}
}
\value{
\code{string}
}
\description{
English uses ',' between every 3 numbers while the
SI format recommends a ' ' if x > 10^4. The scientific
form 10e+? is furthermore avoided.
}
\examples{
txtInt(123)
# Supplying a matrix
txtInt(matrix(c(1234, 12345, 123456, 1234567), ncol = 2))
# Missing are returned as empty strings, i.e. ""
txtInt(c(NA, 1e7))
}
\seealso{
Other text formatters:
\code{\link{txtMergeLines}()},
\code{\link{txtPval}()},
\code{\link{txtRound}()}
}
\concept{text formatters}
htmlTable/man/prGetThead.Rd 0000644 0001762 0000144 00000007472 13701421460 015267 0 ustar ligges users % Generated by roxygen2: do not edit by hand
% Please edit documentation in R/htmlTable_render_getThead.R
\name{prGetThead}
\alias{prGetThead}
\title{Renders the table head (thead)}
\usage{
prGetThead(
x,
header = NULL,
cgroup = NULL,
n.cgroup = NULL,
caption = NULL,
compatibility,
total_columns,
css.cgroup,
top_row_style,
rnames,
rowlabel = NULL,
cgroup_spacer_cells,
prepped_cell_css,
style_list,
cell_style
)
}
\arguments{
\item{x}{The matrix/data.frame with the data. For the \code{print} and \code{knit_print}
it takes a string of the class \code{htmlTable} as \code{x} argument.}
\item{header}{A vector of character strings specifying column
header, defaulting to \code{\link[base:colnames]{colnames(x)}}}
\item{cgroup}{A vector, matrix or list of character strings defining major column header. The default
is to have none. These elements are also known as \emph{column spanners}. If you want a column \emph{not}
to have a spanner then put that column as "". If you pass cgroup and \code{n.crgroup} as
matrices you can have column spanners for several rows. See cgroup section below for details.}
\item{n.cgroup}{An integer vector, matrix or list containing the number of columns for which each element in
cgroup is a heading. For example, specify \code{cgroup=c("Major_1","Major_2")},
\code{n.cgroup=c(3,3)} if \code{"Major_1"} is to span columns 1-3 and
\code{"Major_2"} is to span columns 4-6.
\code{rowlabel} does not count in the column numbers. You can omit \code{n.cgroup}
if all groups have the same number of columns. If the \code{n.cgroup} is one less than
the number of columns in the matrix/data.frame then it automatically adds those.}
\item{caption}{Adds a table caption.}
\item{compatibility}{Is default set to \code{LibreOffice} as some
settings need to be in old HTML format as Libre Office can't
handle some commands such as the css caption-alignment. Note: this
option is not yet fully implemented for all details, in the future
I aim to generate a HTML-correct table and one that is aimed
at Libre Office compatibility. Word-compatibility is difficult as
Word ignores most settings and destroys all layout attempts
(at least that is how my 2010 version behaves). You can additinally use the
\code{options(htmlTableCompat = "html")} if you want a change to apply
to the entire document.
MS Excel sometimes misinterprets certain cell data when opening HTML-tables (eg. 1/2 becomes 1. February).
To avoid this please specify the correct Microsoft Office format for each cell in the table using the css.cell-argument.
To make MS Excel interpret everything as text use "mso-number-format:\"\\@\"".}
\item{total_columns}{The total number of columns including the rowlabel and the
specer cells}
\item{top_row_style}{The top row has a special style depending on
the \code{ctable} option in the \code{htmlTable} call.}
\item{rnames}{Default row names are generated from \code{\link[base:colnames]{rownames(x)}}. If you
provide \code{FALSE} then it will skip the row names. \emph{Note:} For \code{data.frames}
if you do \code{\link[base:colnames]{rownames(my_dataframe) <- NULL}} it still has
row names. Thus you need to use \code{FALSE} if you want to
supress row names for \code{data.frames}.}
\item{rowlabel}{If the table has row names or \code{rnames},
\code{rowlabel} is a character string containing the
column heading for the \code{rnames}.}
\item{cgroup_spacer_cells}{The spacer cells due to the multiple cgroup levels.
With multiple rows in cgroup we need to keep track of how many spacer cells
occur between the columns. This variable contains is of the size \code{ncol(x)-1}
and 0 if there is no cgroup element between.}
\item{style_list}{The list with all the styles}
}
\value{
\code{string} Returns the html string for the \verb{...} element
}
\description{
Renders the table head (thead)
}
\keyword{internal}
htmlTable/man/txtMergeLines.Rd 0000644 0001762 0000144 00000002337 14165130172 016027 0 ustar ligges users % Generated by roxygen2: do not edit by hand
% Please edit documentation in R/txtFrmt.R
\name{txtMergeLines}
\alias{txtMergeLines}
\title{A merges lines while preserving the line break for HTML/LaTeX}
\usage{
txtMergeLines(..., html = 5)
}
\arguments{
\item{...}{The lines that you want to be joined}
\item{html}{If HTML compatible output should be used. If \code{FALSE}
it outputs LaTeX formatting. Note if you set this to 5
then the HTML5 version of \emph{br} will be used: \verb{
}
otherwise it uses the \verb{
} that is compatible
with the XHTML-formatting.}
}
\value{
\code{string} with \code{asis_output} wrapping if html output is activated
}
\description{
This function helps you to do a table header with multiple lines
in both HTML and in LaTeX. In HTML this isn't that tricky, you just use
the \verb{
} command but in LaTeX I often find
myself writing \code{vbox}/\code{hbox} stuff and therefore
I've created this simple helper function
}
\examples{
txtMergeLines("hello", "world")
txtMergeLines("hello", "world", html=FALSE)
txtMergeLines("hello", "world", list("A list", "is OK"))
}
\seealso{
Other text formatters:
\code{\link{txtInt}()},
\code{\link{txtPval}()},
\code{\link{txtRound}()}
}
\concept{text formatters}
htmlTable/man/prPrepareCgroup.Rd 0000644 0001762 0000144 00000004004 13730316012 016342 0 ustar ligges users % Generated by roxygen2: do not edit by hand
% Please edit documentation in R/htmlTable_helpers_prepareCgroup.R
\name{prPrepareCgroup}
\alias{prPrepareCgroup}
\title{Prepares the cgroup argument}
\usage{
prPrepareCgroup(x, cgroup = NULL, n.cgroup = NULL, style_list)
}
\arguments{
\item{x}{The matrix/data.frame with the data. For the \code{print} and \code{knit_print}
it takes a string of the class \code{htmlTable} as \code{x} argument.}
\item{cgroup}{A vector, matrix or list of character strings defining major column header. The default
is to have none. These elements are also known as \emph{column spanners}. If you want a column \emph{not}
to have a spanner then put that column as "". If you pass cgroup and \code{n.crgroup} as
matrices you can have column spanners for several rows. See cgroup section below for details.}
\item{n.cgroup}{An integer vector, matrix or list containing the number of columns for which each element in
cgroup is a heading. For example, specify \code{cgroup=c("Major_1","Major_2")},
\code{n.cgroup=c(3,3)} if \code{"Major_1"} is to span columns 1-3 and
\code{"Major_2"} is to span columns 4-6.
\code{rowlabel} does not count in the column numbers. You can omit \code{n.cgroup}
if all groups have the same number of columns. If the \code{n.cgroup} is one less than
the number of columns in the matrix/data.frame then it automatically adds those.}
}
\value{
\code{list(cgroup, n.cgroup, align.cgroup, cgroup_spacer_cells)}
}
\description{
Due to the complicated structure of multilevel cgroups there
some preparation for the cgroup options is required.
}
\seealso{
Other hidden helper functions for htmlTable:
\code{\link{prAddCells}()},
\code{\link{prAddEmptySpacerCell}()},
\code{\link{prAddSemicolon2StrEnd}()},
\code{\link{prEscapeHtml}()},
\code{\link{prGetCgroupHeader}()},
\code{\link{prGetRowlabelPos}()},
\code{\link{prGetStyle}()},
\code{\link{prPrepInputMatrixDimensions}()},
\code{\link{prPrepareAlign}()},
\code{\link{prTblNo}()}
}
\concept{hidden helper functions for htmlTable}
\keyword{internal}
htmlTable/man/htmlTableWidget-shiny.Rd 0000644 0001762 0000144 00000002264 13701421460 017442 0 ustar ligges users % Generated by roxygen2: do not edit by hand
% Please edit documentation in R/htmlTableWidget.R
\name{htmlTableWidget-shiny}
\alias{htmlTableWidget-shiny}
\alias{htmlTableWidgetOutput}
\alias{renderHtmlTableWidget}
\title{Shiny bindings for htmlTableWidget}
\usage{
htmlTableWidgetOutput(outputId, width = "100\%", height = "400px")
renderHtmlTableWidget(expr, env = parent.frame(), quoted = FALSE)
}
\arguments{
\item{outputId}{output variable to read from}
\item{width, height}{Must be a valid CSS unit (like \code{'100\%'}, \code{'400px'}, \code{'auto'}) or a number,
which will be coerced to a string and have \code{'px'} appended.}
\item{expr}{An expression that generates a \code{\link[=htmlTableWidget]{htmlTableWidget()}}}
\item{env}{The environment in which to evaluate \code{expr}.}
\item{quoted}{Is \code{expr} a quoted expression (with \code{quote()})? This
is useful if you want to save an expression in a variable.}
}
\description{
Output and render functions for using htmlTableWidget within Shiny
applications and interactive Rmd documents.
}
\examples{
\dontrun{
# In the UI:
htmlTableWidgetOutput("mywidget")
# In the server:
renderHtmlTableWidget({
htmlTableWidget(iris)
})
}
}
htmlTable/man/prEscapeHtml.Rd 0000644 0001762 0000144 00000001770 13730316012 015620 0 ustar ligges users % Generated by roxygen2: do not edit by hand
% Please edit documentation in R/htmlTable_helpers_escapeHtml.R
\name{prEscapeHtml}
\alias{prEscapeHtml}
\title{Remove html entities from table}
\usage{
prEscapeHtml(x)
}
\arguments{
\item{x}{The matrix/data.frame with the data. For the \code{print} and \code{knit_print}
it takes a string of the class \code{htmlTable} as \code{x} argument.}
}
\value{
\code{x} without the html entities
}
\description{
Removes the htmlEntities from table input data. Note that
this also replaces $ signs in order to remove the MathJax
issue.
}
\seealso{
Other hidden helper functions for htmlTable:
\code{\link{prAddCells}()},
\code{\link{prAddEmptySpacerCell}()},
\code{\link{prAddSemicolon2StrEnd}()},
\code{\link{prGetCgroupHeader}()},
\code{\link{prGetRowlabelPos}()},
\code{\link{prGetStyle}()},
\code{\link{prPrepInputMatrixDimensions}()},
\code{\link{prPrepareAlign}()},
\code{\link{prPrepareCgroup}()},
\code{\link{prTblNo}()}
}
\concept{hidden helper functions for htmlTable}
htmlTable/man/prTblNo.Rd 0000644 0001762 0000144 00000002200 13730316012 014576 0 ustar ligges users % Generated by roxygen2: do not edit by hand
% Please edit documentation in R/htmlTable_helpers_tblNo.R
\name{prTblNo}
\alias{prTblNo}
\title{Gets the table counter string}
\usage{
prTblNo(caption = NULL)
}
\arguments{
\item{caption}{The caption if any}
}
\value{
\code{string} Returns a string formatted according to
the table_counter_str and table_counter_roman. The number is
decided by the table_counter variable
}
\description{
Returns the string used for htmlTable to number the different tables.
Uses options \code{table_counter}, \code{table_counter_str},
and \code{table_counter_roman} to produce the final string. You
can set each option by simply calling \code{options()}.
}
\seealso{
Other hidden helper functions for htmlTable:
\code{\link{prAddCells}()},
\code{\link{prAddEmptySpacerCell}()},
\code{\link{prAddSemicolon2StrEnd}()},
\code{\link{prEscapeHtml}()},
\code{\link{prGetCgroupHeader}()},
\code{\link{prGetRowlabelPos}()},
\code{\link{prGetStyle}()},
\code{\link{prPrepInputMatrixDimensions}()},
\code{\link{prPrepareAlign}()},
\code{\link{prPrepareCgroup}()}
}
\concept{hidden helper functions for htmlTable}
\keyword{internal}
htmlTable/man/prPrepareColors.Rd 0000644 0001762 0000144 00000001110 13701421460 016341 0 ustar ligges users % Generated by roxygen2: do not edit by hand
% Please edit documentation in R/htmlTable_helpers_prepareColors.R
\name{prPrepareColors}
\alias{prPrepareColors}
\title{Prepares the alternating colors}
\usage{
prPrepareColors(clr, n = NULL, ng = NULL, gtxt)
}
\arguments{
\item{clr}{The colors}
\item{n}{The number of rows/columns applicable to the color}
\item{ng}{The n.rgroup/n.cgroup argument if applicable}
\item{gtxt}{The rgroup/cgroup texts}
}
\value{
\code{character} A vector containing hexadecimal colors
}
\description{
Prepares the alternating colors
}
\keyword{internal}
htmlTable/man/addStyles.Rd 0000644 0001762 0000144 00000020074 13730316012 015163 0 ustar ligges users % Generated by roxygen2: do not edit by hand
% Please edit documentation in R/htmlTable_style_handlers.R
\name{addHtmlTableStyle}
\alias{addHtmlTableStyle}
\alias{appendHtmlTableStyle}
\title{Add/set css and other style options}
\usage{
addHtmlTableStyle(
x,
align = NULL,
align.header = NULL,
align.cgroup = NULL,
css.rgroup = NULL,
css.rgroup.sep = NULL,
css.tspanner = NULL,
css.tspanner.sep = NULL,
css.total = NULL,
css.cell = NULL,
css.cgroup = NULL,
css.header = NULL,
css.header.border_bottom = NULL,
css.class = NULL,
css.table = NULL,
pos.rowlabel = NULL,
pos.caption = NULL,
col.rgroup = NULL,
col.columns = NULL,
padding.rgroup = NULL,
padding.tspanner = NULL,
spacer.celltype = NULL,
spacer.css.cgroup.bottom.border = NULL,
spacer.css = NULL,
spacer.content = NULL
)
appendHtmlTableStyle(
x,
align = NULL,
align.header = NULL,
align.cgroup = NULL,
css.rgroup = NULL,
css.rgroup.sep = NULL,
css.tspanner = NULL,
css.tspanner.sep = NULL,
css.total = NULL,
css.cell = NULL,
css.cgroup = NULL,
css.header = NULL,
css.header.border_bottom = NULL,
css.class = NULL,
css.table = NULL,
pos.rowlabel = NULL,
pos.caption = NULL,
col.rgroup = NULL,
col.columns = NULL,
padding.rgroup = NULL,
padding.tspanner = NULL,
spacer.celltype = NULL,
spacer.css.cgroup.bottom.border = NULL,
spacer.css = NULL,
spacer.content = NULL
)
}
\arguments{
\item{x}{The object that you later want to pass into \code{\link[=htmlTable]{htmlTable()}}.}
\item{align}{A character strings specifying column alignments, defaulting to \code{'c'}
to center. Valid chars for alignments are l = left, c = center and r = right. You can also specify
\code{align='c|c'} and other LaTeX tabular formatting. If you want to set the alignment of the
rownames this string needst to be \code{ncol(x) + 1}, otherwise it automatically
pads the string with a left alignment for the rownames.}
\item{align.header}{A character strings specifying alignment for column header,
defaulting to centered, i.e. \verb{[paste][base::paste](rep('c',ncol(x)),collapse='')}.}
\item{align.cgroup}{The justification of the \code{cgroups}}
\item{css.rgroup}{CSS style for the rgroup, if different styles are wanted for each of the
rgroups you can just specify a vector with the number of elements.}
\item{css.rgroup.sep}{The line between different rgroups. The line is set to the TR element
of the lower rgroup, i.e. you have to set the border-top/padding-top etc to a line with
the expected function. This is only used for rgroups that are printed. You can specify
different separators if you give a vector of rgroup - 1 length (this is since the first
rgroup doesn't have a separator).}
\item{css.tspanner}{The CSS style for the table spanner.}
\item{css.tspanner.sep}{The line between different spanners.}
\item{css.total}{The css of the total row if such is activated.}
\item{css.cell}{The css.cell element allows you to add any possible CSS style to your
table cells. See section below for details.}
\item{css.cgroup}{The same as \code{css.class} but for cgroup formatting.}
\item{css.header}{The header style, not including the cgroup style}
\item{css.header.border_bottom}{The header bottom-border style, e.g. \verb{border-bottom: 1px solid grey}}
\item{css.class}{The html CSS class for the table. This allows directing html
formatting through \href{https://www.w3schools.com/Css/}{CSS}
directly at all instances of that class. \emph{Note:} unfortunately the
CSS is frequently ignored by word processors. This option
is mostly inteded for web-presentations.}
\item{css.table}{You can specify the the style of the table-element using this parameter}
\item{pos.rowlabel}{Where the rowlabel should be positioned. This value can be \code{"top"},
\code{"bottom"}, \code{"header"}, or a integer between \code{1} and \code{nrow(cgroup) + 1}. The options
\code{"bottom"} and \code{"header"} are the same, where the row label is presented at the same level as
the header.}
\item{pos.caption}{Set to \code{"bottom"} to position a caption below the table
instead of the default of \code{"top"}.}
\item{col.rgroup}{Alternating colors (zebra striping/banded rows) for each \code{rgroup}; one or two colors
is recommended and will be recycled.}
\item{col.columns}{Alternating colors for each column.}
\item{padding.rgroup}{Generally two non-breakings spaces, i.e. \verb{ }, but some
journals only have a bold face for the rgroup and leaves the subelements unindented.}
\item{padding.tspanner}{The table spanner is usually without padding but you may specify padding
similar to \code{padding.rgroup} and it will be added to all elements, including the rgroup elements.
This allows for a 3-level hierarchy if needed.}
\item{spacer.celltype}{When using cgroup the table headers are separated through a empty
HTML cell that is by default filled with \verb{ } (no-breaking-space) that prevents the cell
from collapsing. The purpose of this is to prevent the headers underline to bleed into one
as the underline is for the entire cell. You can alter this behavior by changing this option,
valid options are \code{single_empty}, \code{skip}, \code{double_cell}. The \code{single_empty} is the default,
the \code{skip} lets the header bleed into one and skips entirely, \code{double_cell} is for having
two cells so that a vertical border ends up centered (specified using the \code{align} option).
The arguments are matched internally using \link[base:match.arg]{base::match.arg} so you can specify only a part
of the name, e.g. \code{"sk"} will match \code{"skip"}.}
\item{spacer.css.cgroup.bottom.border}{Defaults to \code{none} and used for separating cgroup headers.
Due to a browser bug this is sometimes ignored and you may therefore need to set this
to \verb{1px solid white} to enforce a white border.}
\item{spacer.css}{If you want the spacer cells to share settings you can set it here}
\item{spacer.content}{Defaults to \verb{ } as this guarantees that the cell is not collapsed
and is highly compatible when copy-pasting to word processors.}
}
\value{
\code{x} with the style added as an attribute that the htmlTable then can use for formatting.
}
\description{
This function is a preprocessing step before applying the \code{\link[=htmlTable]{htmlTable()}} function.
You use this to style your tables with HTML cascading style sheet features.
}
\details{
The function stores the current theme (see \code{\link[=setHtmlTableTheme]{setHtmlTableTheme()}}) + custom styles
to the provided object as an \code{\link[base:attributes]{base::attributes()}}. It is stored under the element
\code{htmlTable.style} in the form of a list object.
}
\section{The \code{css.cell} argument}{
The \code{css.cell} parameter allows you to add any possible CSS style
to your table cells. \code{css.cell} can be either a vector or a matrix.
If \code{css.cell} is a \emph{vector}, it's assumed that the styles should be repeated
throughout the rows (that is, each element in css.cell specifies the style
for a whole column of 'x').
In the case of \code{css.cell} being a \emph{matrix} of the same size of the \code{x} argument,
each element of \code{x} gets the style from the corresponding element in css.cell. Additionally,
the number of rows of \code{css.cell} can be \code{nrow(x) + 1} so the first row of of \code{css.cell}
specifies the style for the header of \code{x}; also the number of columns of \code{css.cell}
can be \code{ncol(x) + 1} to include the specification of style for row names of \code{x}.
Note that the \code{text-align} CSS field in the \code{css.cell} argument will be overriden
by the \code{align} argument.
Excel has a specific css-style, \code{mso-number-format} that can be used for improving the
copy-paste functionality. E.g. the style could be written as: \verb{css_matrix <- matrix( data = "mso-number-format:\\"\\\\@\\"", nrow = nrow(df), ncol = ncol(df))}
}
\examples{
library(magrittr)
matrix(1:4, ncol = 2) \%>\%
addHtmlTableStyle(align = "c", css.cell = "background-color: orange;") \%>\%
htmlTable(caption = "A simple style example")
}
\seealso{
Other htmlTableStyle:
\code{\link{hasHtmlTableStyle}()}
}
\concept{htmlTableStyle}
htmlTable/man/prGetAlign.Rd 0000644 0001762 0000144 00000001610 13730316012 015256 0 ustar ligges users % Generated by roxygen2: do not edit by hand
% Please edit documentation in R/htmlTable_helpers_getAlign.R
\name{prGetAlign}
\alias{prGetAlign}
\title{Gets alignment}
\usage{
prGetAlign(
align,
index,
style_list = NULL,
spacerCell = FALSE,
followed_by_spacer_cell = FALSE,
previous_was_spacer_cell = FALSE
)
}
\arguments{
\item{align}{A character strings specifying column alignments, defaulting to \code{'c'}
to center. Valid chars for alignments are l = left, c = center and r = right. You can also specify
\code{align='c|c'} and other LaTeX tabular formatting. If you want to set the alignment of the
rownames this string needst to be \code{ncol(x) + 1}, otherwise it automatically
pads the string with a left alignment for the rownames.}
\item{index}{The index of the align parameter of interest}
}
\description{
Gets alignment
}
\concept{hidden helper functions for}
\keyword{internal}
htmlTable/man/tblNoLast.Rd 0000644 0001762 0000144 00000001255 13701421460 015133 0 ustar ligges users % Generated by roxygen2: do not edit by hand
% Please edit documentation in R/tblNo.R
\name{tblNoLast}
\alias{tblNoLast}
\title{Gets the last table number}
\usage{
tblNoLast(roman = getOption("table_counter_roman", FALSE))
}
\arguments{
\item{roman}{Whether or not to use roman numbers instead
of arabic. Can also be set through \code{options(table_caption_no_roman = TRUE)}}
}
\description{
The function relies on \code{options("table_counter")}
in order to keep track of the last number.
}
\examples{
org_opts <- options(table_counter=1)
tblNoLast()
options(org_opts)
}
\seealso{
Other table functions:
\code{\link{htmlTable}},
\code{\link{tblNoNext}()}
}
\concept{table functions}
htmlTable/man/tblNoNext.Rd 0000644 0001762 0000144 00000001255 13701421460 015146 0 ustar ligges users % Generated by roxygen2: do not edit by hand
% Please edit documentation in R/tblNo.R
\name{tblNoNext}
\alias{tblNoNext}
\title{Gets the next table number}
\usage{
tblNoNext(roman = getOption("table_counter_roman", FALSE))
}
\arguments{
\item{roman}{Whether or not to use roman numbers instead
of arabic. Can also be set through \code{options(table_caption_no_roman = TRUE)}}
}
\description{
The function relies on \code{options("table_counter")}
in order to keep track of the last number.
}
\examples{
org_opts <- options(table_counter=1)
tblNoNext()
options(org_opts)
}
\seealso{
Other table functions:
\code{\link{htmlTable}},
\code{\link{tblNoLast}()}
}
\concept{table functions}
htmlTable/man/prMergeClr.Rd 0000644 0001762 0000144 00000001220 13701421460 015263 0 ustar ligges users % Generated by roxygen2: do not edit by hand
% Please edit documentation in R/htmlTable_helpers_mergeClr.R
\name{prMergeClr}
\alias{prMergeClr}
\title{Merges multiple colors}
\usage{
prMergeClr(clrs)
}
\arguments{
\item{clrs}{The colors}
}
\value{
\code{character} A hexadecimal color
}
\description{
Uses the \code{\link[grDevices:colorRamp]{colorRampPalette()}} for merging colors.
\emph{Note:} When merging more than 2 colors the order in the color
presentation matters. Each color is merged with its neigbors before
merging with next. If there is an uneven number of colors the middle
color is mixed with both left and right side.
}
\keyword{internal}
htmlTable/man/getHtmlTableStyle.Rd 0000644 0001762 0000144 00000001322 13730316012 016617 0 ustar ligges users % Generated by roxygen2: do not edit by hand
% Please edit documentation in R/htmlTable_style_handlers.R
\name{getHtmlTableStyle}
\alias{getHtmlTableStyle}
\title{Get style options for object}
\usage{
getHtmlTableStyle(x)
}
\arguments{
\item{x}{The object intended for \code{\link[=htmlTable]{htmlTable()}}.}
}
\value{
A \code{list} if the attribute exists, otherwise \code{NULL}
}
\description{
A wrap around the \code{\link[base:attr]{base::attr()}} that retrieves the style
attribute used by \code{\link[=htmlTable]{htmlTable()}} (\code{htmlTable.style}).
}
\examples{
library(magrittr)
mx <- matrix(1:4, ncol = 2)
colnames(mx) <- LETTERS[1:2]
mx \%>\%
addHtmlTableStyle(align = "l|r") \%>\%
getHtmlTableStyle()
}
htmlTable/man/prGetCgroupHeader.Rd 0000644 0001762 0000144 00000005065 13730316012 016604 0 ustar ligges users % Generated by roxygen2: do not edit by hand
% Please edit documentation in R/htmlTable_render_getCgroupHeader.R
\name{prGetCgroupHeader}
\alias{prGetCgroupHeader}
\title{Retrieve a header row}
\usage{
prGetCgroupHeader(
x,
cgroup_vec,
n.cgroup_vec,
cgroup_vec.just,
row_no,
top_row_style,
rnames,
rowlabel = NULL,
cgroup_spacer_cells,
style_list,
prepped_cell_css,
css_4_cgroup_vec
)
}
\arguments{
\item{x}{The matrix/data.frame with the data. For the \code{print} and \code{knit_print}
it takes a string of the class \code{htmlTable} as \code{x} argument.}
\item{cgroup_vec}{The \code{cgroup} may be a \code{matrix}, this is
just one row of that \code{matrix}}
\item{n.cgroup_vec}{The same as above but for the counter}
\item{cgroup_vec.just}{The same as above bot for the justification}
\item{row_no}{The row number within the header group. Useful for multi-row
headers when we need to output the \code{rowlabel} at the \code{pos.rowlabel}
level.}
\item{top_row_style}{The top row has a special style depending on
the \code{ctable} option in the \code{htmlTable} call.}
\item{rnames}{Default row names are generated from \code{\link[base:colnames]{rownames(x)}}. If you
provide \code{FALSE} then it will skip the row names. \emph{Note:} For \code{data.frames}
if you do \code{\link[base:colnames]{rownames(my_dataframe) <- NULL}} it still has
row names. Thus you need to use \code{FALSE} if you want to
supress row names for \code{data.frames}.}
\item{rowlabel}{If the table has row names or \code{rnames},
\code{rowlabel} is a character string containing the
column heading for the \code{rnames}.}
\item{cgroup_spacer_cells}{The spacer cells due to the multiple cgroup levels.
With multiple rows in cgroup we need to keep track of how many spacer cells
occur between the columns. This variable contains is of the size \code{ncol(x)-1}
and 0 if there is no cgroup element between.}
\item{style_list}{The list with all the styles}
}
\value{
\code{string}
}
\description{
This function retrieves a header row, i.e. a row
within the \verb{} elements on top of the table. Used by
\code{\link[=htmlTable]{htmlTable()}}.
}
\seealso{
Other hidden helper functions for htmlTable:
\code{\link{prAddCells}()},
\code{\link{prAddEmptySpacerCell}()},
\code{\link{prAddSemicolon2StrEnd}()},
\code{\link{prEscapeHtml}()},
\code{\link{prGetRowlabelPos}()},
\code{\link{prGetStyle}()},
\code{\link{prPrepInputMatrixDimensions}()},
\code{\link{prPrepareAlign}()},
\code{\link{prPrepareCgroup}()},
\code{\link{prTblNo}()}
}
\concept{hidden helper functions for htmlTable}
\keyword{internal}
htmlTable/man/prAddSemicolon2StrEnd.Rd 0000644 0001762 0000144 00000001672 13730316012 017337 0 ustar ligges users % Generated by roxygen2: do not edit by hand
% Please edit documentation in R/htmlTable_helpers_addSemicolon2StrEnd.R
\name{prAddSemicolon2StrEnd}
\alias{prAddSemicolon2StrEnd}
\title{Add a ; at the end}
\usage{
prAddSemicolon2StrEnd(my_str)
}
\arguments{
\item{my_str}{The string that is to be processed}
}
\value{
\code{string}
}
\description{
The CSS expects a semicolon at the end of each argument
this function just adds a semicolong if none is given
and remove multiple semicolon if such exist
}
\seealso{
Other hidden helper functions for htmlTable:
\code{\link{prAddCells}()},
\code{\link{prAddEmptySpacerCell}()},
\code{\link{prEscapeHtml}()},
\code{\link{prGetCgroupHeader}()},
\code{\link{prGetRowlabelPos}()},
\code{\link{prGetStyle}()},
\code{\link{prPrepInputMatrixDimensions}()},
\code{\link{prPrepareAlign}()},
\code{\link{prPrepareCgroup}()},
\code{\link{prTblNo}()}
}
\concept{hidden helper functions for htmlTable}
\keyword{internal}
htmlTable/man/htmlTableWidget.Rd 0000644 0001762 0000144 00000002425 13572272225 016322 0 ustar ligges users % Generated by roxygen2: do not edit by hand
% Please edit documentation in R/htmlTableWidget.R
\name{htmlTableWidget}
\alias{htmlTableWidget}
\title{htmlTable with pagination widget}
\usage{
htmlTableWidget(
x,
number_of_entries = c(10, 25, 100),
width = NULL,
height = NULL,
elementId = NULL,
...
)
}
\arguments{
\item{x}{A data frame to be rendered}
\item{number_of_entries}{a numeric vector with the number of entries per page to show.
If there is more than one number given, the user will be able to show the number
of rows per page in the table.}
\item{width}{Fixed width for widget (in css units). The default is
\code{NULL}, which results in intelligent automatic sizing based on the
widget's container.}
\item{height}{Fixed height for widget (in css units). The default is
\code{NULL}, which results in intelligent automatic sizing based on the
widget's container.}
\item{elementId}{Use an explicit element ID for the widget (rather than an
automatically generated one). Useful if you have other JavaScript that
needs to explicitly discover and interact with a specific widget instance.}
\item{...}{Additional parameters passed to htmlTable}
}
\value{
an htmlwidget showing the paginated table
}
\description{
This widget renders a table with pagination into an htmlwidget
}
htmlTable/man/prBindDataListIntoColumns.Rd 0000644 0001762 0000144 00000001055 13701421460 020266 0 ustar ligges users % Generated by roxygen2: do not edit by hand
% Please edit documentation in R/tidyHtmlTable_helpers_bindDataListIntoColumns.r
\name{prBindDataListIntoColumns}
\alias{prBindDataListIntoColumns}
\title{Merge columns into a tibble}
\usage{
prBindDataListIntoColumns(dataList)
}
\arguments{
\item{dataList}{\code{list} with the columns/data.frames}
}
\value{
\code{data.frame} object
}
\description{
Almost the same as \code{\link[tibble:tibble]{tibble::tibble()}} but it solves the issue
with some of the arguments being columns and some just being vectors.
}
htmlTable/man/prIsNotebook.Rd 0000644 0001762 0000144 00000000654 13701421460 015651 0 ustar ligges users % Generated by roxygen2: do not edit by hand
% Please edit documentation in R/htmlTable_helpers_isNotebook.R
\name{prIsNotebook}
\alias{prIsNotebook}
\title{Detects if the call is made from within an RStudio Rmd file or a file
with the html_notebook output set.}
\usage{
prIsNotebook()
}
\description{
Detects if the call is made from within an RStudio Rmd file or a file
with the html_notebook output set.
}
\keyword{internal}
htmlTable/man/prPrepareAlign.Rd 0000644 0001762 0000144 00000003135 13730316012 016141 0 ustar ligges users % Generated by roxygen2: do not edit by hand
% Please edit documentation in R/htmlTable_helpers_prepareAlign.R
\name{prPrepareAlign}
\alias{prPrepareAlign}
\title{Prepares the align to match the columns}
\usage{
prPrepareAlign(align, x, rnames, default_rn = "l")
}
\arguments{
\item{x}{The matrix/data.frame with the data. For the \code{print} and \code{knit_print}
it takes a string of the class \code{htmlTable} as \code{x} argument.}
\item{rnames}{Default row names are generated from \code{\link[base:colnames]{rownames(x)}}. If you
provide \code{FALSE} then it will skip the row names. \emph{Note:} For \code{data.frames}
if you do \code{\link[base:colnames]{rownames(my_dataframe) <- NULL}} it still has
row names. Thus you need to use \code{FALSE} if you want to
supress row names for \code{data.frames}.}
\item{default_rn}{The default rowname alignment. This is an option
as the header uses the same function and there may be differences in
how the alignments should be implemented.}
}
\description{
The alignment may be tricky and this function therefore simplifies
this process by extending/shortening the alignment to match the
correct number of columns.
}
\seealso{
Other hidden helper functions for htmlTable:
\code{\link{prAddCells}()},
\code{\link{prAddEmptySpacerCell}()},
\code{\link{prAddSemicolon2StrEnd}()},
\code{\link{prEscapeHtml}()},
\code{\link{prGetCgroupHeader}()},
\code{\link{prGetRowlabelPos}()},
\code{\link{prGetStyle}()},
\code{\link{prPrepInputMatrixDimensions}()},
\code{\link{prPrepareCgroup}()},
\code{\link{prTblNo}()}
}
\concept{hidden helper functions for htmlTable}
\keyword{internal}
htmlTable/DESCRIPTION 0000644 0001762 0000144 00000002545 14517543722 013714 0 ustar ligges users Package: htmlTable
Version: 2.4.2
Title: Advanced Tables for Markdown/HTML
Authors@R: c(
person("Max", "Gordon", email = "max@gforge.se",
role = c("aut", "cre")),
person("Stephen", "Gragg", role=c("aut")),
person("Peter", "Konings", role=c("aut")))
Maintainer: Max Gordon
Description: Tables with state-of-the-art layout elements such as row spanners,
column spanners, table spanners, zebra striping, and more. While allowing
advanced layout, the underlying css-structure is simple in order to maximize
compatibility with common word processors. The package also contains a few
text formatting functions that help outputting text compatible with HTML/LaTeX.
License: GPL (>= 3)
URL: https://gforge.se/packages/
BugReports: https://github.com/gforge/htmlTable/issues
Biarch: yes
Depends: R (>= 4.1)
Imports: stringr, knitr (>= 1.6), magrittr (>= 1.5), methods,
checkmate, htmlwidgets, htmltools, rstudioapi (>= 0.6)
Suggests: testthat, XML, xml2, Hmisc, rmarkdown, chron, lubridate,
tibble, purrr, tidyselect, glue, rlang, tidyr (>= 0.7.2), dplyr
(>= 0.7.4)
Encoding: UTF-8
NeedsCompilation: no
VignetteBuilder: knitr
RoxygenNote: 7.2.2
Packaged: 2023-10-29 14:13:52 UTC; max
Author: Max Gordon [aut, cre],
Stephen Gragg [aut],
Peter Konings [aut]
Repository: CRAN
Date/Publication: 2023-10-29 21:00:02 UTC
htmlTable/build/ 0000755 0001762 0000144 00000000000 14517464237 013302 5 ustar ligges users htmlTable/build/vignette.rds 0000644 0001762 0000144 00000000470 14517464237 015642 0 ustar ligges users N0ӏ
:@uyh&qAHܦzRLin7Q.)mUqbSloBO#~ F35>ۈbVCQvPdz+dٿ}ROuV9rG5L2>_A z~ |