html_args {opm}R Documentation

HTML formatting and output label generation

Description

These are helper functions for phylo_data allowing for either the easy fine-tuning of the generated HTML output or for the conversions of strings to safe phylogenetic taxon labels.

Usage

  html_args(character.states = c(`negative reaction` = "-", `weak reaction` = "w",
    `positive reaction` = "+"),
    multiple.sep = "/", organisms.start = "Organisms: ",
    states.start = "Symbols: ", legend.dot = TRUE,
    legend.sep.1 = ", ", legend.sep.2 = "; ",
    table.summary = "character matrix", no.html = TRUE,
    greek.letters = TRUE, css.file = opm_opt("css.file"),
    embed.css = FALSE, ...)

  safe_labels(x, format, enclose = TRUE, pad = FALSE,
    comment = FALSE)

Arguments

character.states

Character vector used for mapping integers to the elements in the corresponding position. It is also used in conjunction with its names to create the table legend. The default value is useful for data of mode ‘logical’, mapping FALSE, NA and TRUE, in this order. Data of this kind are by default internally converted to an according integer vector.

multiple.sep

Character scalar used for joining multiple-state characters together.

organisms.start

Character scalar prepended to the organism part of the table legend. Ignored if empty.

states.start

Character scalar prepended to the character-states part of the table legend. Ignored if empty.

legend.dot

Logical scalar indicating whether or not a dot shall be appended to the table-legend entries.

legend.sep.1

Character scalar used for the first pass of joining the table-legend entries together.

legend.sep.2

Character scalar used for the second pass of joining the table-legend entries together.

table.summary

Character scalar inserted as ‘summary’ attribute of the resulting HTML table.

no.html

Logical scalar indicating whether substrate names should be cleaned from characters that might interfere with HTML code. Setting this to FALSE might yield invalid HTML.

greek.letters

Logical scalar indicating whether or not letters between ‘a’ and ‘e’ within substrate names should be converted to the corresponding Greek letters. This is done after the cleaning step, if any.

css.file

Character vector indicating the name of one to several CSS files to link or embed. Empty strings and empty vectors are ignored. If embed.css is FALSE it is no error if the file does not exist, but the page will then probably not be displayed as intended.

Under Windows it is recommended to convert a file name f using normalizePath(f, winslash = "/") before linking it.

embed.css

Logical scalar indicating whether or not CSS files shall be embedded, not linked.

...

Optional other arguments available for inserting user-defined HTML content. Currently the following ones (in their order of insertion) are not ignored, and can even be provided several times:

meta

Used as (additional) ‘meta’ entries within the HTML head.

headline

Override the use of the title argument as headline (placed above the table legend). An empty argument would turn it off.

prepend

List or character vector to be inserted before the table legend. Lists are converted recursively. List names will be converted to ‘title’ and ‘class’ attributes (if missing, names are inferred from the nesting level; see opm_opt, entry html.class). Names of other vectors, if any, are converted to ‘title’ and ‘span’ attributes. Character vectors are converted using safe_labels unless they inherit from AsIs (see I from the base package).

insert

As above, but inserted between the legend and the table.

append

As above, but inserted after the table.

x

Character vector or convertible to such.

format

Character scalar. See phylo_data.

enclose

Logical scalar. See phylo_data and the description of comment.

pad

Logical scalar. Bring labels to the same number of characters by appending spaces? Has no effect for PHYLIP and HTML output format.

comment

Logical scalar. If TRUE, comments as used in the respective format will be produced. PHYLIP and EPF do not accept comments and will yield an error. If enclose is TRUE, the comment-enclosing characters are appended and prepended to the vector, otherwise to each string separately.

Details

These functions are not normally called directly by an opm user but by phylo_data; see there for their usual application. The phylo_data methods for OPMD_Listing and OPMS_Listing objects do not support all HTML formatting options.

Label cleaning invokes either the replacement of disallowed characters or the enclosing of all labels in single quotes and the doubling of already existing single quotes, if any.

Value

List of HTML arguments or character vector with modified labels.

See Also

base::normalizePath base::I base::gsub

Other phylogeny-functions: phylo_data

Examples

# Some animals you might know
x <- c("Elephas maximus", "Loxodonta africana", "Giraffa camelopardalis")

(y <- safe_labels(x, "phylip"))
## [1] "Elephas_ma" "Loxodonta_" "Giraffa_ca"
stopifnot(nchar(y) == 10L) # truncation

(y <- safe_labels(x, "epf"))
## [1] "Elephas_maximus"        "Loxodonta_africana"    
## [3] "Giraffa_camelopardalis"
stopifnot(nchar(y) == nchar(x)) # changes in length unnecessary
(y <- safe_labels(x, "epf", pad = TRUE))
## [1] "Elephas_maximus       " "Loxodonta_africana    "
## [3] "Giraffa_camelopardalis"
stopifnot(nchar(y) == 22) # padded to uniform length

(y <- safe_labels(x, "nexus", enclose = TRUE))
## [1] "'Elephas maximus'"        "'Loxodonta africana'"    
## [3] "'Giraffa camelopardalis'"
stopifnot(grepl("^'.*'$", y)) # all strings enclosed in sinqle quotes

[Package opm version 1.3.63 Index]