metOption: Get Metaplot Option with Partial Matching

View source: R/utils.R

metOptionR Documentation

Get Metaplot Option with Partial Matching

Description

Gets a metaplot option value from the named list getOption('metaplot'). If an exact match is not found, trailing elements of x, separated by underscore, are removed one at a time in search of a partial match. Thus 'ref.col' will match for 'ref.col_dens' and 'ref.col_scatter' if neither of these is set (allowing selective override). However, global' will never match 'global.col'.

Usage

metOption(x, default = NULL)

Arguments

x

a character string holding an option name

default

the value returned if option is not set

Details

If x is missing a list of all metaplot options is returned.

See Also

getOption setOption

Examples


library(magrittr)
library(dplyr)
library(csv)
x <- as.csv(system.file(package = 'metaplot', 'extdata/theoph.csv'))
x %<>% pack

multiplot(
x %>% metaplot(conc, gg = F),
x %>% metaplot(conc, time, gg = F),
x %>% metaplot(conc, arm, gg = F),
x %>% metaplot(conc, arm,  gg = T)
)

# Add a reference line at 9 mg/L
x$conc %<>% structure(reference = 9)

# Make the reference line green universally.
setOption(ref_col = 'green')

# Make the reference line orange for density plots
setOption(ref_col_dens = 'orange')

multiplot(
x %>% metaplot(conc, gg = F),
x %>% metaplot(conc, time, gg = F),
x %>% metaplot(conc, arm, gg = F),
x %>% metaplot(conc, arm,  gg = T)
)

# Restore defaults
# setOption() # clears all metaplot options
setOption(ref_col = NULL)
setOption(ref_col_dens = NULL)

bergsmat/metaplot documentation built on Feb. 21, 2024, 1:18 p.m.