metaplot: Metaplot

Description Usage Arguments Details See Also Examples

View source: R/metaplot.R

Description

Metaplot creates univariate, bivariate, or multivariate plots depending on the number and types of variables represented by the anonymous arguments. Types are either numeric (NUM, e.g. real, integer) or categorical (CAT, e.g. factor, character). A variable stored as numeric that nonetheless has an encoded guide attribute will be treated as categorical. Mnemonic: x %>% metaplot(yvars, xvar, groupvar, facets) where arguments are unquoted column names, and only xvar is required. Column attributes label, guide, reference, and symbol modify the behavior of the default handlers.

Usage

1

Arguments

x

object

...

passed arguments

Details

Design your plot by specifying y variables (optional), the x variable, the groups variable (optional) and the conditioning variables (i.e., facets, optional).

The single groups variable, if any, is the first categorical in the third position or later. An earlier categorical gives a "mixed" bivariate plot or mosaic plot, depending on the type of the remaining variable.

The x variable is the last variable before groups, if present.

The y variables are those before x. If none, the result is univariate. If one, the result is typically a boxplot or scatterplot, depending on x. Several numeric y followed by a numeric x are treated as multivariate (scatterplot matrix). But if all y have the same guide attribute and it is different from that for x, the result is bivariate (i.e, an overlay scatterplot).

A single categorical variable results in a simple mosaic plot (see link[graphics]{mosaicplot} and vcd for more sophisticated treatment). Mosaic plots support only a single y variable; thus, whenever the first two variables are categorical, a two-way mosaic plot results, with remaining variables understood as groups and facets.

Wherever a groups argument is meaningful, it may be missing. This allows specification of facets in the absence of groups, e.g., (metaplot(y, x, , facet1, facet2)). For multiple y (overlay), the sources of y are the implied groups: any trailing categorical arguments are treated as facets.

Template designs follow; substitute behaviors by setting global options (see argument list).

Variable attributes may be supplied by conventional means; pack and unpack support storing and retrieving scalar column attributes. The following scalar attributes are currently supported.

See Also

Other generic functions: axislabel, categorical, corsplom, densplot, pack, scatter, test_metaplot, unpack

Other metaplot: boxplot_data_frame, categorical_data_frame, corsplom_data_frame, densplot_data_frame, metaplot_key, scatter_data_frame, test_metaplot

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
library(magrittr)
library(dplyr)
library(csv)
x <- as.csv(system.file(package = 'metaplot', 'extdata/theoph.csv'))
x %<>% pack
# setOption(gg = TRUE)
# setOption(verbose = TRUE)  # all messages; equiv. to metaplot(verbose = T,...)
# setOption(verbose_densplot = TRUE) # densplot messages
# sample plots
x %>% metaplot(sres)
x %>% metaplot(site)
x %>% metaplot(conc, arm)
x %>% densplot(conc, arm)
x %>% metaplot(arm, conc)
x %>% metaplot(conc, arm, site)
x %>% metaplot(conc, site, arm)
x %>% metaplot(conc, time)
x %>% metaplot(arm, site)
x %>% metaplot(arm, site, cohort)
x %>% metaplot(arm, site, cohort, space = 'top')
x %>% metaplot(arm, site, , cohort)
x %>% metaplot(conc, time, subject)
x %>% metaplot(conc, time, , subject)
x %>% metaplot(conc, time, subject, site)
x %>% metaplot(conc, time, subject, site, arm)
x %>% metaplot(lKe, lKa, lCl)


x %>% metaplot(
  lKe, lKa, lCl,
  col = 'black',smooth.col = 'red', pin.col = 'red',
  dens.col='blue',dens.alpha = 0.1
)
x %>% metaplot(conc, pred, ipred, time, space = 'top')
x %>% metaplot(conc, pred, ipred, time, subject, space = 'top')
x %>% metaplot(conc, pred, ipred, time, subject,
  colors = c('black','blue','orange'),
  points = c(0.9,0, 0.4),
  lines = c(F,T,T),
  types = c('blank','dashed','solid'),
  space = 'top'
)

x %>% metaplot(conc, ipred, time, site, arm, space = 'top')
x %>% metaplot(res, conc, yref = 0, ysmooth = T, conf = T, grid = T, loc = 1)
x %>% metaplot(res, conc, arm, ysmooth = T, conf = T )
x %>% metaplot(res, conc, arm, ysmooth = T, conf = T, global = T, ref.col = 'red')
x %>% metaplot(subject,conc)

# manage metadata
attr(x$arm, 'guide') # //1/Arm A//2/Arm B//

x %>% metaplot(conc, arm) # default

x %>% mutate(arm = arm %>%
  structure(guide = '//2/Arm B//1/Arm A//')) %>%
  metaplot(conc, arm) # different presentation order

x %>% mutate(arm = arm %>%
  structure(guide = '//1/Both Arms//2/Both Arms//')) %>%
  metaplot(conc, arm) # collapse cases

metaplot documentation built on Sept. 30, 2018, 5:05 p.m.

Related to metaplot in metaplot...