scatter_data_frame {metaplot}R Documentation

Scatterplot Function for Data Frame

Description

Scatterplot function for class 'data.frame'.

Usage

scatter_data_frame(
  x,
  yvar,
  xvar,
  groups = NULL,
  facets = NULL,
  log = metOption("log_scatter", FALSE),
  ylog = metOption("ylog_scatter", log),
  xlog = metOption("xlog_scatter", log),
  crit = metOption("crit_scatter", 1.3),
  yref = metOption("yref_scatter", "metaplot_ref"),
  xref = metOption("xref_scatter", "metaplot_ref"),
  ylab = metOption("ylab_scatter", "axislabel"),
  xlab = metOption("xlab_scatter", "axislabel"),
  ysmooth = metOption("ysmooth_scatter", FALSE),
  xsmooth = metOption("xsmooth_scatter", FALSE),
  iso = metOption("iso_scatter", FALSE),
  na.rm = metOption("na.rm_scatter", TRUE),
  aspect = metOption("aspect_scatter", 1),
  space = metOption("space_scatter", "right"),
  key = metOption("key_scatter", "metaplot_key"),
  as.table = metOption("as.table_scatter", TRUE),
  prepanel = metOption("prepanel_scatter", NULL),
  isoprepanel = metOption("isoprepanel_scatter", "iso_prepanel"),
  scales = metOption("scales_scatter", NULL),
  panel = metOption("panel_scatter", "scatter_panel"),
  points = metOption("points_scatter", TRUE),
  colors = metOption("colors_scatter", NULL),
  fill = metOption("fill_scatter", NULL),
  symbols = metOption("symbols_scatter", NULL),
  sizes = metOption("sizes_scatter", 1),
  types = metOption("types_scatter", "solid"),
  widths = metOption("widths_scatter", 1),
  lines = metOption("lines_scatter", FALSE),
  main = metOption("main_scatter", NULL),
  sub = metOption("sub_scatter", NULL),
  subscripts = metOption("subscripts_scatter", TRUE),
  settings = metOption("settings_scatter", NULL),
  padding = metOption("padding_scatter", 1),
  ref.col = metOption("ref.col_scatter", "grey"),
  ref.lty = metOption("ref.lty_scatter", "solid"),
  ref.lwd = metOption("ref.lwd_scatter", 1),
  ref.alpha = metOption("ref.alpha_scatter", 1),
  xref.col = metOption("xref.col_scatter", NULL),
  xref.lty = metOption("xref.lty_scatter", NULL),
  xref.lwd = metOption("xref.lwd_scatter", NULL),
  xref.alpha = metOption("xref.alpha_scatter", NULL),
  yref.col = metOption("yref.col_scatter", NULL),
  yref.lty = metOption("yref.lty_scatter", NULL),
  yref.lwd = metOption("yref.lwd_scatter", NULL),
  yref.alpha = metOption("yref.alpha_scatter", NULL),
  smooth.lty = metOption("smooth.lty_scatter", "dashed"),
  smooth.lwd = metOption("smooth.lwd_scatter", 1),
  smooth.alpha = metOption("smooth.alpha_scatter", 1),
  fit = metOption("fit_scatter", conf),
  fit.lty = metOption("fit.lty_scatter", "solid"),
  fit.lwd = metOption("fit.lwd_scatter", 1),
  fit.alpha = metOption("fit.alpha_scatter", 1),
  conf = metOption("conf_scatter", FALSE),
  conf.alpha = metOption("conf.alpha_scatter", 0.3),
  loc = metOption("loc_scatter", 0),
  global = metOption("global_scatter", FALSE),
  global.col = metOption("global.col_scatter", "grey"),
  global.fill = metOption("global.fill_scatter", "grey"),
  msg = metOption("msg_scatter", "metastats"),
  gg = metOption("gg_scatter", FALSE),
  verbose = metOption("verbose", FALSE),
  ...
)

Arguments

x

data.frame

yvar

character: y variable(s)

xvar

character: x variable

groups

optional grouping variable; ignored if more than one yvar

facets

optional conditioning variables

log

a default shared by ylog and xlog

ylog

log transform y axis (auto-selected if NA)

xlog

log transform x axis (auto-selected if NA)

crit

if ylog or xlog missing, log transform if mean/median ratio for non-missing values is greater than crit

yref

reference line from y axis; can be function(x = x, var = yvar, ...) or NULL to suppress

xref

reference line from x axis; can be function(x = x, var = xvar, ...) or NULL to suppress

ylab

y axis label; can be function(x = x, var = yvar, log = ylog, ..)

xlab

x axis label; can be function(x = x, var = xvar, log = xlog, ..)

ysmooth

supply loess smooth of y on x

xsmooth

supply loess smmoth of x on y

iso

logical: plot line of unity (auto-selected if NA); can be a (partial) list of aesthetics (col, lty, lwd, alpha)

na.rm

whether to remove data points with one or more missing coordinates

aspect

passed to bwplot or ggplot; use 'fill', NA, or NULL to calculate automatically

space

location of key (right, left, top, bottom)

key

list: passed to xyplot as auto.key or to theme; can be a function groups name, groups levels, points, lines, space, gg, and ... . See metaplot_key.

as.table

passed to xyplot

prepanel

passed to xyplot (guessed if NULL)

isoprepanel

passed to xyplot if iso is TRUE

scales

passed to xyplot or facet_grid or facet_wrap (guessed if NULL)

panel

name or definition of panel function

points

whether to plot points and fill for each group: logical, or alpha values between 0 and 1

colors

replacements for default colors in group order; can be length one integer to auto-select that many colors

fill

replacements for default fill colors in group order (means something different for densplot_data_frame and categorical_data_frame). Used for confidence regions and for filling symbols (pch 21:25).

symbols

replacements for default symbols in group order (i.e. values of pch)

sizes

replacements for default symbol sizes in group order

types

replacements for default line types in group order

widths

replacements for default line widths in group order

lines

whether to plot lines for each group: logical, or alpha values between 0 and 1. Points are connected in the order in which they appear in the data.

main

character, or a function of x, yvar, xvar, groups, facets, and log

sub

character, or a function of x, yvar, xvar, groups, facets, and log

subscripts

passed to xyplot

settings

default parameter settings: a list from which matching elements are passed to lattice (as par.settings) or to ggplot theme() and facet_wrap() or facet_grid(). ncol and nrow are used as layout indices for lattice (for homology with facet_wrap). Also merged with ....

padding

numeric (will be recycled to length 4) giving plot margins in default units: top, right, bottom, left (in multiples of 5.5 points for ggplot)

ref.col

default shared by xref.col and yref.col; can be length one integer to auto-select that many colors

ref.lty

default shared by xref.lty and yref.lty

ref.lwd

default shared by xref.lwd and yref.lwd

ref.alpha

default shared by xref.alpha and yref.alpha

xref.col

x reference line color (recycled)

xref.lty

x reference line type (recycled)

xref.lwd

x reference line size (recycled)

xref.alpha

x reference line alpha (recycled)

yref.col

y reference line color (recycled)

yref.lty

y reference line type (recycled)

yref.lwd

y reference line size (recycled)

yref.alpha

y reference line alpha (recycled)

smooth.lty

smooth line type

smooth.lwd

smooth line size

smooth.alpha

smooth alpha

fit

draw a linear fit of y ~ x

fit.lty

fit line type

fit.lwd

fit line size

fit.alpha

fit alpha

conf

logical, or width for a confidence region around a linear fit; passed to region; TRUE defaults to 95 percent confidence interval; may not make sense if xlog is TRUE

conf.alpha

alpha transparency for confidence region

loc

where to print statistics on a panel; suppressed for grouped plots an facetted ggplots

global

if TRUE, xsmooth, ysmooth, fit, and conf are applied to all data rather than groupwise

global.col

color for global aesthetics

global.fill

fill color for global aesthetics

msg

a function to print text on a panel: called with x values, y values, and ....

gg

logical: whether to generate ggplot instead of trellis

verbose

generate messages describing process

...

passed to called functions e.g., region

See Also

scatter_panel

Other bivariate plots: iso_prepanel(), metaplot.data.frame(), scatter.data.frame(), scatter()

Other metaplot: boxplot_data_frame(), categorical_data_frame(), corsplom_data_frame(), densplot_data_frame(), metaplot_key(), metaplot(), test_metaplot()

Other scatter: metaplot_key(), scatter.data.frame(), scatter_panel(), scatter()

Examples

library(magrittr)
library(dplyr)
attr(Theoph$conc,'label') <- 'theophylline concentration'
attr(Theoph$conc,'guide') <- 'mg/L'
attr(Theoph$Time,'label') <- 'time'
attr(Theoph$Time,'guide') <- 'h'
attr(Theoph$Subject,'guide') <- '////'
scatter_data_frame(Theoph, 'conc', 'Time')
scatter_data_frame(Theoph, 'conc','Time', 'Subject')
scatter_data_frame(Theoph, 'conc','Time', facets = 'Subject')
scatter_data_frame(Theoph %>% filter(conc > 0), 'conc','Time', 'Subject',ylog = TRUE, yref = 5)
scatter_data_frame(Theoph, 'conc','Time', 'Subject',ylog = TRUE, yref = 5)
scatter_data_frame(Theoph, 'conc','Time', 'Subject',ysmooth = TRUE)
scatter_data_frame(Theoph, 'conc','Time', 'Subject',ysmooth = TRUE,global = TRUE)
scatter_data_frame(Theoph, 'conc','Time', conf = TRUE, loc = 3, yref = 6)
scatter_data_frame(Theoph, 'conc','Time', conf = TRUE, loc = 3, yref = 6)

[Package metaplot version 0.8.4 Index]