latexTherm {Hmisc} | R Documentation

## Create LaTeX Thermometers and Colored Needles

### Description

`latexTherm` creates a LaTeX picture environment for drawing a series of thermometers whose heights depict the values of a variable `y` assumed to be scaled from 0 to 1. This is useful for showing fractions of sample analyzed in any table or plot, intended for a legend. For example, four thermometers might be used to depict the fraction of enrolled patients included in the current analysis, the fraction randomized, the fraction of patients randomized to treatment A being analyzed, and the fraction randomized to B being analyzed. The picture is placed inside a LaTeX macro definition for macro variable named `name`, to be invoked by the user later in the LaTeX file using `name` preceeded by a backslash.

If `y` has an attribute `"table"`, it is assumed to contain a character string with LaTeX code. This code is used as a tooltip popup for PDF using the LaTeX `ocgtools` package or using style `tooltips`. Typically the code will contain a `tabular` environment. The user must define a LaTeX macro `tooltipn` that takes two arguments (original object and pop-up object) that does the pop-up.

`latexNeedle` is similar to `latexTherm` except that vertical needles are produced and each may have its own color. A grayscale box is placed around the needles and provides the 0-1 `y`-axis reference. Horizontal grayscale grid lines may be drawn.

### Usage

    latexTherm(y, name, w = 0.075, h = 0.15, spacefactor = 1/2, extra = 0.07,
               file = "", append = TRUE)

    latexNeedle(y, col='black', href=0.5, name, w=.05, h=.15,
                extra=0, file = "", append=TRUE)

### Arguments

`y` | a vector of 0-1 scaled values. Boxes and their frames are omitted for `NA` elements
`name` | name of LaTeX macro variable to be defined
`w` | width of a single box (thermometer) in inches. For `latexNeedle` is the spacing between needles.
`h` | height of a single box in inches. For `latexNeedle` is the height of the frame.
`spacefactor` | fraction of `w` added for extra space between boxes for `latexTherm`
`extra` | extra space in inches to set aside to the right of and above the series of boxes or frame
`file` | name of file to which to write LaTeX code. Default is the console.
`append` | set to `FALSE` to write over `file`
`col` | a vector of colors corresponding to positions in `y`. `col` is repeated if too short.
`href` | values of `y` (0-1) for which horizontal grayscale reference lines are drawn for `latexNeedle`. Set to `NULL` to not draw any.

### Author(s)

Frank Harrell

### Examples

    ## Not run:
    # The following is in the Hmisc tests directory
    # For a knitr example see latexTherm.Rnw in that directory
    ct <- function(...) cat(..., sep='')
    ct('\documentclass{report}\begin{document}\n')
    latexTherm(c(1, 1, 1, 1), name='lta')
    latexTherm(c(.5, .7, .4, .2), name='ltb')
    latexTherm(c(.5, NA, .75, 0), w=.3, h=1, name='ltc', extra=0)
    latexTherm(c(.5, NA, .75, 0), w=.3, h=1, name='ltcc')
    latexTherm(c(0, 0, 0, 0), name='ltd')
    ct('This is a the first:\lta and the second:\ltb\\ and the third
    without extra:\ltc END\\\nThird with extra:\ltcc END\\
    \vspace{2in}\\
    All data = zero, frame only:\ltd\\
    \end{document}\n')

    ## End(Not run)

[Package Hmisc version 3.17-4 Index]