Learn R Programming

metaplot (version 0.2.1)

metaplot: Metaplot

Description

Creates a metaplot.

Creates a metaplot from grouped_df. Folds x and calls the method for folded. Dots arguments are passed only to metaplot.

Creates a metaplot from data.frame. Folds x and calls the method for folded. Dots arguments are passed only to metaplot.

Creates a plot from folded, using metadata as available.

Usage

metaplot(x, ...)

# S3 method for grouped_df metaplot(x, ...)

# S3 method for data.frame metaplot(x, ...)

# S3 method for folded metaplot(x, ...)

Arguments

x

object

...

passed arguments

Methods (by class)

  • grouped_df: grouped_df method

  • data.frame: data.frame method

  • folded: folded method

Details

Metaplot creates univariate, bivariate, or multivariate plots depending on the number and type of items represented by the anonymous arguments.

  • CON: A single argument representing a continuous variable (numeric, not having encoded GUIDE) is forwarded to dens.folded to give a density plot.

  • CAT: A single categorical argument is unexpected.

  • CON, CAT: Two arguments, types continuous and categorical, are forwarded to boxplot.folded to give a boxplot (vertical or horizontal, depending on order).

  • CON, CON: Two arguments representing continuous variables give a scatterplot (first vs. second) by means of scatter.folded.

  • CAT, CAT: Two anonymous categorical arguments are unexpected.

  • CON, CAT, ARG: A third anonymous argument is unexpected if a preceding argument is categorical.

  • CON, CON, CAT: A third, categorical argument following two continuous arguments is treated as a grouping variable.

  • CON, CON, CON: If there are three or more continuous arguments, a scatterplot matrix is created by means of corsplom.folded. However....

  • CON, CON, CON, CAT (,CAT): For three or more continuous arguments, if one or more categorical arguments are present, an overlay plot will be created by means of overlay.folded: other continuous items will be plotted vs. the last continuous item; up to two categorical items will be used as conditioning variables (facets).

Stratification, e.g. conditioning for trellis plots, is currently unimplemented.

See Also

Other generic functions: axislabel, continuous, corsplom, dens, guide, label, overlay, scatter

Other metaplots: metapanel

Other univariate plots: dens

Other bivariate plots: boxplot, scatter

Other multivariate plots: corsplom, overlay.data.frame, overlay.folded

Other metaplots: metapanel

Other univariate plots: dens

Other bivariate plots: boxplot, scatter

Other multivariate plots: corsplom, overlay.data.frame, overlay.folded

Other metaplots: metapanel

Other univariate plots: dens

Other bivariate plots: boxplot, scatter

Other multivariate plots: corsplom, overlay.data.frame, overlay.folded

Examples

Run this code
# NOT RUN {
# quick example

library(magrittr)
library(fold)
x <- as.folded(system.file(package='metaplot','extdata','drug1001.fld'))
x %>% metaplot(
 DV, IPRE, SEX,
 ylog = TRUE,
 xlog = TRUE,
 grid = TRUE, # passed to xyplot
 iso = TRUE,
 ysmooth = TRUE,
 xsmooth = TRUE,
 yref = 0.5,
 xref = 0.5,
 main = TRUE,
 corr = TRUE,
 fit = TRUE,
 conf = 1 - 1e-14,
 loc = 6
)

# extended examples

# }
# NOT RUN {
# load some packages
library(spec)
library(csv)
library(magrittr)
library(tidyr)
library(dplyr)
library(fold)

# find paths to example data and specification
x <- system.file(package='metaplot','extdata','drug1001.csv')
spec <- system.file(package='metaplot','extdata','drug1001.spec')

# verify agreement at file level
x %matches% spec

# read and verify in memory
x %<>% as.csv
spec %<>% as.spec
x %matches% spec

# convert specifaction to folded format
spec %<>%  as.folded

# capture the most interesting parts of x
x %<>% filter(VISIBLE == 1) %>% filter(EVID == 0)

# identify keys
attr(x, 'groups') <- c('ID','TIME')

# fold x
x %<>% fold

# combine with metadata
x %<>% bind_rows(spec)
x %<>% sort
# x %>% as.csv('drug1001.fld')

# Now we have a plotting dataset with embedded metadata.
# We call metaplot with various numbers of continuous and
# categorical arguments, given as unquoted values from the
# VARIABLE column.

x %>% metaplot(AGE) # one continuous
x %>% metaplot(PRED,DV) # two continuous
x %>% metaplot(AGE,SEX) # continuous and categorical
x %>% metaplot(SEX,AGE, main = TRUE) # categorical and continuous
x %>% metaplot(PRED,DV,SEX, main = TRUE) # two continous and categorical
x %>% metaplot(ETA1,ETA2,ETA3) # three or more continuous
x %>% metaplot(CWRES,TAD) # metadata
x %>% filter(META %>% is.na) %>% metaplot(CWRES,TAD) # no metadata
x %>% metaplot(PRED,DV, xlog = TRUE, ylog = TRUE, iso=TRUE, xsmooth = TRUE) # log-log
x %>% metaplot(CWRES, TAD, yref = 0, ysmooth = TRUE)
x %>% metaplot(ETA1, SEX, ref = 0)
x %>% metaplot(AGE,WEIGHT, ysmooth = TRUE, xsmooth = TRUE)
x %>% metaplot(AGE,WEIGHT, ysmooth = TRUE)
x %>% metaplot(AGE,WEIGHT, ysmooth = TRUE, fit = TRUE)
x %>% metaplot(AGE,WEIGHT, ysmooth = TRUE, conf = TRUE)
x %>% metaplot(AGE,WEIGHT, ysmooth = TRUE, conf = TRUE, loc = 9)
x %>% metaplot(AGE,WEIGHT, ysmooth = TRUE, conf = TRUE, loc = c(.2,.7),
main = TRUE, corr = TRUE)

# FED ~ WEIGHT would normally invoke a boxplot.
# Here we force FED to be treated as numeric to illustrate logistic regression.
x %>% scatter('FED', 'WEIGHT', conf = TRUE)
# Alternatively:
x %>%
filter(is.na(META) | !(VARIABLE == 'FED' & META =='GUIDE')) %>%
metaplot(FED, WEIGHT, conf = TRUE)

# Below, x is TAD,
# plot is conditioned by ID
# ID is categorical (encoded)

x %>% metaplot(
  DV, PRED, IPRE, TAD, ID,
  color = 'black',
  points = c(TRUE, FALSE, FALSE),
  line   = c('none','dashed','solid'),
  ylab = 'plasma drug concentration (ng/mL)'
) %>% `[[`(1)

2-way facetting
x %>% metaplot(DV, PRED, TIME, SEX, FED,
line = 'none', color = c('blue','magenta'))
# }

Run the code above in your browser using DataLab