m_scatter: Generates a matrix of scatter plots

m_scatterR Documentation

Generates a matrix of scatter plots

Description

m_scatter generates a matrix of pairwise scatter plots to graphically investigate possible associations between variables.

Usage

m_scatter(
  data,
  data_type = "dat",
  lookup = NULL,
  yr = 1,
  popn = 1,
  param = "N",
  vs = NA,
  save2disk = TRUE,
  fname = NULL,
  dir_out = "Plots"
)

Arguments

data

The output from collate_dat, the long format of the output from collate_run or the output from con_l_yr

data_type

The type of input data. Possible options are 'dat', 'yr' or 'run'

lookup

A table to add relevant variable matched using the scenarios names

yr

The year to be plotted

popn

The sequential number of the population (in integer)

param

The parameter to be plotted in the last raw

vs

The parameters to be plotted

save2disk

Whether to save the output to disk, default: TRUE

fname

The name of the files where to save the output

dir_out

The local path to store the output. Default: Plots

Details

The output from collate_dat is the preferred input for this function as large datasets will require a long time to be plotted.

It may be convenient to pass the dependent variable of a regression model with param so that all the pairwise scatter plots of this variable will be in one line.

Value

A matrix of scatter plots

Examples

# Using Pacioni et al. example data. See ?pac.lhs for more details.
data(pac.lhs)
# Remove base scenario
pac.lhs.no.base <- pac.lhs[!pac.lhs$scen.name == 'ST_LHS(Base)', ]

# Get correct parameter values at year 0
lkup.ST_LHS <- lookup_table(
    data=pac.lhs.no.base, project='Pacioni_et_al',
    scenario='ST_LHS',
    pop='Population 1',
    SVs=c('SV1', 'SV2', 'SV3', 'SV4', 'SV5', 'SV6', 'SV7'),
    save2disk=FALSE)

scatter.plot <- m_scatter(
    data=pac.lhs.no.base[1:33],
    data_type='dat',
    lookup=lkup.ST_LHS,
    yr=120,
    popn=1,
    param='Nall',
    vs=c('SV1', 'SV2', 'SV3'),
    save2disk=FALSE)

carlopacioni/vortexR documentation built on May 6, 2022, 12:07 p.m.