Title: | Graphical Tools for Exploring Data with 'iNZight' |
---|---|
Description: | Simple plotting function(s) for exploratory data analysis with flexible options allowing for easy plot customisation. The goal is to make it easy for beginners to start exploring a dataset through simple R function calls, as well as provide a similar interface to summary statistics and inference information. Includes functionality to generate interactive HTML-driven graphs. Used by 'iNZight', a graphical user interface providing easy exploration and visualisation of data for students of statistics, available in both desktop and online versions. |
Authors: | Tom Elliott [aut, cre] |
Maintainer: | Tom Elliott <[email protected]> |
License: | GPL-3 |
Version: | 2.15.4.9000 |
Built: | 2025-01-28 21:29:19 UTC |
Source: | https://github.com/inzightvit/inzightplots |
Several iNZightPlots graphs have been enabled with custom interaction, while others make use of the automatic output of 'plotly'. This function returns 'TRUE' if the provided plot has interaction (as determined by iNZight), and 'FALSE' otherwise.
can.interact(x) ## Default S3 method: can.interact(x) ## S3 method for class 'inzplotoutput' can.interact(x) ## S3 method for class 'ggplot' can.interact(x)
can.interact(x) ## Default S3 method: can.interact(x) ## S3 method for class 'inzplotoutput' can.interact(x) ## S3 method for class 'ggplot' can.interact(x)
x |
a plot object returned from a plotting function |
Not that, while most 'ggplot2' graphs can be passed to 'plotly', and even though we are using plot.ly directly for some of our ggplot2 graphs, we still only return 'TRUE' if the graph was created by one of the packages in the iNZight collection.
Logical to identify if there is an interactive version
can.interact(default)
: Default interaction helper (always returns 'FALSE')
can.interact(inzplotoutput)
: Graphs from 'iNZightPlot()', many of which
have interaction enabled, but some do not (for example, hex plots)
can.interact(ggplot)
: Those 'iNZight*' plotting functions which return
a 'ggplot2' object and have been tested to work with plotly
will be tagged as such; this is just a helper to check for
the necessary attribute.
Tom Elliott, Yu Han Soh
can.interact(iNZightPlot(Sepal.Length, data = iris))
can.interact(iNZightPlot(Sepal.Length, data = iris))
This function was misspelled in earlier versions
and has been corrected to cont_palette_names
,
which should be used instead.
const_palette_names()
const_palette_names()
a list of continuous colour palettes
Construct plot call from settings list
construct_call( settings, vartypes, data = quote(.dataset), design = quote(.design), what = c("plot", "summary", "inference") )
construct_call( settings, vartypes, data = quote(.dataset), design = quote(.design), what = c("plot", "summary", "inference") )
settings |
a list of plot settings, similar to |
vartypes |
a list of variables types (numeric, factor) |
data |
a data set to pass to the call |
design |
a survey design (can be NULL) |
what |
the type of call to produce |
a plot/summary/inference call
Convert a numeric variable in to a factor with four levels.
convert.to.factor(x)
convert.to.factor(x)
x |
a numeric vector |
a factor variable
Tom Elliott
f <- convert.to.factor(runif(100, 0, 10)) levels(f)
f <- convert.to.factor(runif(100, 0, 10)) levels(f)
Create a Plot Object
create(obj, ...)
create(obj, ...)
obj |
an object |
... |
additional arguments |
This create method is to be used by packages extending 'iNZightPlots',
and should not be used by users. The resulting object should have
an associated plot
method.
an iNZight plot object with class determined by data type
Tom Elliott
Emphasize a level or interval of a colour palette
emphasize_pal_colour(n, k, cat = TRUE, ncat = 5, fn)
emphasize_pal_colour(n, k, cat = TRUE, ncat = 5, fn)
n |
the number of colours to draw from the palette |
k |
the index of the colour to emphasize |
cat |
logical indicator if palette is categorical or numeric |
ncat |
the number of intervals to use for continuous palettes |
fn |
the colour palette function to use |
a colour palette, with one level emphasized (or range for numeric)
Tom Elliott
pal <- inzpalette("bright") plot(1:5, pch = 19, col = emphasize_pal_colour(5, 2, fn = pal))
pal <- inzpalette("bright") plot(1:5, pch = 19, col = emphasize_pal_colour(5, 2, fn = pal))
Allows easy viewing of every variable in the data set. The user will be prompted to see the next variable.
exploreAllPlots(data)
exploreAllPlots(data)
data |
a data frame |
Tom Elliott
if (interactive()) exploreAllPlots(iris)
if (interactive()) exploreAllPlots(iris)
Allows easy access to a summary for every variable in the data set.
exploreAllSummaries(data, ...) ## S3 method for class 'allSummaries' print(x, ...)
exploreAllSummaries(data, ...) ## S3 method for class 'allSummaries' print(x, ...)
data |
a data set |
... |
additional arguments passed to getPlotSummary() |
x |
an |
allSummaries object, a concatenation of summaries from all variables
print(allSummaries)
: print method for allSummaries object
Tom Elliott
exploreAllSummaries(iris)
exploreAllSummaries(iris)
exportHTML
is designed to export the iNZight plot as a dynamic, interactive HTML page.
Currently only handles single panel plots. Coloured hex plots are currently not available yet.
exportHTML( x, file = file.path(dir, "index.html"), data, local = FALSE, dir = tempdir(), extra.vars, ... ) ## S3 method for class ''function'' exportHTML( x, file = file.path(dir, "index.html"), data = NULL, local = FALSE, dir = tempdir(), extra.vars = NULL, width = dev.size()[1], height = dev.size()[2], ... ) ## S3 method for class 'ggplot' exportHTML( x, file = file.path(dir, "index.html"), data = NULL, local = FALSE, dir = tempdir(), extra.vars = NULL, mapObj, ... ) ## S3 method for class 'inzplotoutput' exportHTML( x, file = file.path(dir, "index.html"), data = NULL, local = FALSE, dir = tempdir(), extra.vars = NULL, ... )
exportHTML( x, file = file.path(dir, "index.html"), data, local = FALSE, dir = tempdir(), extra.vars, ... ) ## S3 method for class ''function'' exportHTML( x, file = file.path(dir, "index.html"), data = NULL, local = FALSE, dir = tempdir(), extra.vars = NULL, width = dev.size()[1], height = dev.size()[2], ... ) ## S3 method for class 'ggplot' exportHTML( x, file = file.path(dir, "index.html"), data = NULL, local = FALSE, dir = tempdir(), extra.vars = NULL, mapObj, ... ) ## S3 method for class 'inzplotoutput' exportHTML( x, file = file.path(dir, "index.html"), data = NULL, local = FALSE, dir = tempdir(), extra.vars = NULL, ... )
x |
An iNZight plot object that captures iNZight environment |
file |
Name of temporary HTML file generated (defaults to 'index.html' in a temporary directory, or other as specified using 'dir') |
data |
dataset/dataframe that you wish to investigate and export more variables from |
local |
Logical for creating local files for offline use (default to false) |
dir |
A directory to store the file and output |
extra.vars |
extra variables specified by the user to be exported |
... |
extra arguments |
width |
the desired width of the SVG plot |
height |
the desired height of the SVG plot |
mapObj |
iNZightMap object (from iNZightMaps) |
an inzHTML object consisting of a link to an HTML rendering
of x
with filename file
,
which can be loaded in the browser (for example using browseURL
,
or calling the print()
method of the returned object.
exportHTML(`function`)
: method for an iNZightPlot-generating function
exportHTML(ggplot)
: method for iNZightMaps or other supported ggplot graphs
exportHTML(inzplotoutput)
: method for output from iNZightPlot
Yu Han Soh
## Not run: x <- iNZightPlot(Petal.Width, Petal.Length, data = iris, colby = Species) exportHTML(x, "index.html") #to export more variables for scatterplots: exportHTML(x, "index.html", data = iris, extra.vars = c("Sepal.Length", "Sepal.Width")) ## End(Not run)
## Not run: x <- iNZightPlot(Petal.Width, Petal.Length, data = iris, colby = Species) exportHTML(x, "index.html") #to export more variables for scatterplots: exportHTML(x, "index.html", data = iris, extra.vars = c("Sepal.Length", "Sepal.Width")) ## End(Not run)
exportSVG
is designed to export the iNZight plot as a temporary SVG that is opened in a web browser.
The iNZightPlot must be drawn to a graphics device before exporting can occur.
exportSVG(x, file = tempfile(fileext = ".svg"), ...) ## S3 method for class ''function'' exportSVG( x, file = tempfile(fileext = ".svg"), width = dev.size()[1], height = dev.size()[2], ... ) ## S3 method for class 'inzplotoutput' exportSVG(x, file = tempfile(fileext = ".svg"), ...)
exportSVG(x, file = tempfile(fileext = ".svg"), ...) ## S3 method for class ''function'' exportSVG( x, file = tempfile(fileext = ".svg"), width = dev.size()[1], height = dev.size()[2], ... ) ## S3 method for class 'inzplotoutput' exportSVG(x, file = tempfile(fileext = ".svg"), ...)
x |
iNZight plot object or function that captures iNZight environment |
file |
Name of temporary svg file generated (by default: 'inzightplot.svg') |
... |
additional arguments |
width |
the width of the plot device |
height |
the height of the plot device |
Opens up an SVG file of x
with filename file
in a web browser
exportSVG(`function`)
: method for functions
exportSVG(inzplotoutput)
: method for an existing plot object
Yu Han Soh
Generate summary or inference information for an iNZight plot
getPlotSummary( x, y = NULL, g1 = NULL, g1.level = NULL, g2 = NULL, g2.level = NULL, varnames = list(), colby = NULL, sizeby = NULL, data = NULL, design = NULL, freq = NULL, missing.info = TRUE, inzpars = inzpar(), summary.type = "summary", table.direction = c("horizontal", "vertical"), hypothesis.value = 0, hypothesis.alt = c("two.sided", "less", "greater"), hypothesis.var.equal = FALSE, hypothesis.use.exact = FALSE, hypothesis.test = c("default", "t.test", "anova", "chi2", "proportion"), hypothesis.simulated.p.value = FALSE, hypothesis = list(value = hypothesis.value, alternative = match.arg(hypothesis.alt), var.equal = hypothesis.var.equal, use.exact = hypothesis.use.exact, test = match.arg(hypothesis.test), simulated.p.value = hypothesis.simulated.p.value), survey.options = list(), width = 100, epi.out = FALSE, privacy_controls = NULL, html = FALSE, ..., env = parent.frame() )
getPlotSummary( x, y = NULL, g1 = NULL, g1.level = NULL, g2 = NULL, g2.level = NULL, varnames = list(), colby = NULL, sizeby = NULL, data = NULL, design = NULL, freq = NULL, missing.info = TRUE, inzpars = inzpar(), summary.type = "summary", table.direction = c("horizontal", "vertical"), hypothesis.value = 0, hypothesis.alt = c("two.sided", "less", "greater"), hypothesis.var.equal = FALSE, hypothesis.use.exact = FALSE, hypothesis.test = c("default", "t.test", "anova", "chi2", "proportion"), hypothesis.simulated.p.value = FALSE, hypothesis = list(value = hypothesis.value, alternative = match.arg(hypothesis.alt), var.equal = hypothesis.var.equal, use.exact = hypothesis.use.exact, test = match.arg(hypothesis.test), simulated.p.value = hypothesis.simulated.p.value), survey.options = list(), width = 100, epi.out = FALSE, privacy_controls = NULL, html = FALSE, ..., env = parent.frame() )
x |
a vector (numeric or factor), or the name of a column in the supplied
|
y |
a vector (numeric or factor), or the name of a column in the supplied
|
g1 |
a vector (numeric or factor), or the name of a column in the supplied
|
g1.level |
the name (or numeric position) of the level of |
g2 |
a vector (numeric or factor), or the name of a column in the supplied
|
g2.level |
same as |
varnames |
a list of variable names, with the list named using the appropriate arguments
(i.e., |
colby |
the name of a variable (numeric or factor) to colour points by. In the case of a numeric variable, a continuous colour scale is used, otherwise each level of the factor is assigned a colour |
sizeby |
the name of a (numeric) variable, which controls the size of points |
data |
the name of a data set |
design |
the name of a survey object, obtained from the |
freq |
the name of a frequency variable if the data are frequencies |
missing.info |
logical, if |
inzpars |
allows specification of iNZight plotting parameters over multiple plots |
summary.type |
one of |
table.direction |
one of 'horizontal' (default) or 'vertical' (useful for many categories) |
hypothesis.value |
H0 value for hypothesis test |
hypothesis.alt |
alternative hypothesis (!=, <, >) |
hypothesis.var.equal |
use equal variance assumption for t-test? |
hypothesis.use.exact |
logical, if |
hypothesis.test |
in some cases (currently just two-samples) can perform multiple tests (t-test or ANOVA) |
hypothesis.simulated.p.value |
also calculate (where available) the simulated p-value |
hypothesis |
either NULL for no test, or missing (in which case above arguments are used) |
survey.options |
additional options passed to survey methods |
width |
width for the output, default is 100 characters |
epi.out |
logical, if |
privacy_controls |
optional, pass in confidentialisation and privacy controls (e.g., random rounding, suppression) for microdata |
html |
logical, it |
... |
additional arguments, see |
env |
compatibility argument |
Works much the same as iNZightPlot
an inzight.plotsummary
object with a print method
Tom Elliott
getPlotSummary(Species, data = iris) getPlotSummary(Species, data = iris, summary.type = "inference", inference.type = "conf") # perform hypothesis testing getPlotSummary(Sepal.Length, data = iris, summary.type = "inference", inference.type = "conf", hypothesis.value = 5) # if you prefer a formula interface inzsummary(Sepal.Length ~ Species, data = iris) inzinference(Sepal.Length ~ Species, data = iris) ## confidentialisation and privacy controls # random rounding and suppression: HairEyeColor_df <- as.data.frame(HairEyeColor) inzsummary(Hair ~ Eye, data = HairEyeColor_df, freq = Freq) inzsummary(Hair ~ Eye, data = HairEyeColor_df, freq = Freq, privacy_controls = list( rounding = "RR3", suppression = 10 ) )
getPlotSummary(Species, data = iris) getPlotSummary(Species, data = iris, summary.type = "inference", inference.type = "conf") # perform hypothesis testing getPlotSummary(Sepal.Length, data = iris, summary.type = "inference", inference.type = "conf", hypothesis.value = 5) # if you prefer a formula interface inzsummary(Sepal.Length ~ Species, data = iris) inzinference(Sepal.Length ~ Species, data = iris) ## confidentialisation and privacy controls # random rounding and suppression: HairEyeColor_df <- as.data.frame(HairEyeColor) inzsummary(Hair ~ Eye, data = HairEyeColor_df, freq = Freq) inzsummary(Hair ~ Eye, data = HairEyeColor_df, freq = Freq, privacy_controls = list( rounding = "RR3", suppression = 10 ) )
A general plotting function that automatically detects variable type and draws the appropriate plot. It also provides facilities to add inference information to plots, colour- and size-by variables, and can handle survey data.
iNZightPlot( x, y = NULL, g1 = NULL, g1.level = NULL, g2 = NULL, g2.level = NULL, varnames = list(), colby = NULL, sizeby = NULL, symbolby = NULL, extra.vars, locate = NULL, locate.id = NULL, locate.col = NULL, locate.extreme = NULL, locate.same.level = NULL, highlight = NULL, data = NULL, design = NULL, freq = NULL, missing.info = TRUE, xlab, ylab, show_units = TRUE, new = TRUE, inzpars = inzpar(), layout.only = FALSE, plot = TRUE, xaxis = TRUE, yaxis = TRUE, xlim = NULL, ylim = NULL, zoombars = NULL, hide.legend = FALSE, df, env = parent.frame(), ... )
iNZightPlot( x, y = NULL, g1 = NULL, g1.level = NULL, g2 = NULL, g2.level = NULL, varnames = list(), colby = NULL, sizeby = NULL, symbolby = NULL, extra.vars, locate = NULL, locate.id = NULL, locate.col = NULL, locate.extreme = NULL, locate.same.level = NULL, highlight = NULL, data = NULL, design = NULL, freq = NULL, missing.info = TRUE, xlab, ylab, show_units = TRUE, new = TRUE, inzpars = inzpar(), layout.only = FALSE, plot = TRUE, xaxis = TRUE, yaxis = TRUE, xlim = NULL, ylim = NULL, zoombars = NULL, hide.legend = FALSE, df, env = parent.frame(), ... )
x |
a vector (numeric or factor), or the name of a column in the
supplied |
y |
a vector (numeric or factor), or the name of a column in the
supplied |
g1 |
a vector (numeric or factor), or the name of a column in the
supplied |
g1.level |
the name (or numeric position) of the level of |
g2 |
a vector (numeric or factor), or the name of a column in the
supplied |
g2.level |
same as |
varnames |
a list of variable names, with the list named using
the appropriate arguments
(i.e., |
colby |
the name of a variable (numeric or factor) to colour points by. In the case of a numeric variable, a continuous colour scale is used, otherwise each level of the factor is assigned a colour |
sizeby |
the name of a (numeric) variable, which controls the size of points |
symbolby |
the name of a factor variable to code point symbols |
extra.vars |
the names of any additional variables to be passed through the internal functions to the create and plot methods. |
locate |
variable to label points |
locate.id |
id of points (row numbers) to label, or
an expression that evaluates as a logical vector (e.g., |
locate.col |
the colour to locate points if a variable is not specified |
locate.extreme |
|
locate.same.level |
name of a variable to label points with same level of as those specified with 'locate.id' |
highlight |
|
data |
the name of a data set |
design |
the name of a survey object, obtained from the |
freq |
the name of a frequency variable if the data are frequencies |
missing.info |
logical, if |
xlab |
the text for the x-label |
ylab |
the text for the y-label |
show_units |
logical, if 'TRUE' (default) units will be shown beside axies and legend variable labels |
new |
logical, used for compatibility |
inzpars |
allows specification of iNZight plotting parameters over multiple plots |
layout.only |
logical, if |
plot |
logical, if |
xaxis |
logical, whether or not to draw the x-axis |
yaxis |
logical, whether or not to draw the y-axis |
xlim |
specify the x limits of the plot |
ylim |
specify the y limits of the plot |
zoombars |
numeric, length 2; when drawing a bar plot, if the number of bars is too large, the user can specify a subset. The first value is the starting point (1 is the first bar, etc), while the second number is the number of bars to show. |
hide.legend |
logical, if TRUE, the |
df |
compatibility argument |
env |
compatibility argument |
... |
additional arguments, see |
The main goal of 'iNZightPlots' is to make it easy to beginners to explore a dataset graphically, using a suite of simple arguments to add features to their graph.
The second use of this function is within the companion software 'iNZight', providing a single function call with arguments controlled by the user through a GUI.
An inzightplotoutput
object, which contains the information
displayed in the plot
Tom Elliott
iNZightPlot(Species, data = iris) iNZightPlot(Petal.Width, g1 = Species, data = iris) iNZightPlot(Sepal.Length, Sepal.Width, data = iris, colby = Species) iNZightPlot(Sepal.Length, Sepal.Width, data = iris, colby = Species, trend = c("linear", "quadratic"), trend.by = TRUE, trend.parallel = FALSE) # add inference information iNZightPlot(Petal.Width, data = iris, inference.type = "conf", inference.par = "mean") iNZightPlot(Petal.Width, data = iris, inference.type = "conf", inference.par = "mean", bootstrap = TRUE) # alternatively, use the formula interface inzplot(Sepal.Length ~ Sepal.Width | Species, data = iris)
iNZightPlot(Species, data = iris) iNZightPlot(Petal.Width, g1 = Species, data = iris) iNZightPlot(Sepal.Length, Sepal.Width, data = iris, colby = Species) iNZightPlot(Sepal.Length, Sepal.Width, data = iris, colby = Species, trend = c("linear", "quadratic"), trend.by = TRUE, trend.parallel = FALSE) # add inference information iNZightPlot(Petal.Width, data = iris, inference.type = "conf", inference.par = "mean") iNZightPlot(Petal.Width, data = iris, inference.type = "conf", inference.par = "mean", bootstrap = TRUE) # alternatively, use the formula interface inzplot(Sepal.Length ~ Sepal.Width | Species, data = iris)
A generic function used to generate inferential information for objects within the iNZight ecosystem.
inzinference(x, ..., env = parent.frame()) ## S3 method for class 'formula' inzinference( x, data = NULL, design = NULL, type = c("conf", "comp"), ..., env = parent.frame() )
inzinference(x, ..., env = parent.frame()) ## S3 method for class 'formula' inzinference( x, data = NULL, design = NULL, type = c("conf", "comp"), ..., env = parent.frame() )
x |
An object |
... |
additional arguments for methods |
env |
an environment to evaluate things |
data |
Dataset to plotq |
design |
A survey design to use |
type |
Type type of inference to obtain, one of 'conf' or 'comp' for confidence intervals and comparison intervals, respectively (currently ignored). |
The output depends on the type of input, and consists of a inference object with a print
method.
inzinference(formula)
: Wrapper for getPlotSummary to obtain inference information about a plot
Used to obtain a colour palette of a given name. A list of available palettes can be obtained by 'cat_palette_names()' and 'cont_palette_names()'.
inzpalette(palette) cat_palette_names() cont_palette_names()
inzpalette(palette) cat_palette_names() cont_palette_names()
palette |
the name of a palette |
a colour palette function with single argument 'n'
cat_palette_names()
: List of categorical colour palettes
cont_palette_names()
: List of continuous colour palettes
Tom Elliott
plot(1:5, pch = 19, col = inzpalette("bright")(5)) # for a list of palette names cat_palette_names() cont_palette_names()
plot(1:5, pch = 19, col = inzpalette("bright")(5)) # for a list of palette names cat_palette_names() cont_palette_names()
Plotting parameters for iNZight Plots
inzpar(..., .viridis = requireNamespace("viridis", quietly = TRUE))
inzpar(..., .viridis = requireNamespace("viridis", quietly = TRUE))
... |
If arguments are supplied, then these values are set. If left empty, then |
.viridis |
checks if the viridis package is installed; or can be turned off the default list is returned. |
A whole suite of parameters that can be used to fine-tune plots obtained from the
iNZightPlot
function.
The parameters include both plot type, style, and appearance.
the plotting symbol to be used; default is '21' (circle with fill)
the colour of points. this can either be a single value, or a vector of
colours if colby
is specified
a function to use for colouring points, etc., or the name of a palette,
see inzpalette
emphasize the chosen level of a colour by variable. For numeric
colour by, col.emphn
specifies the number of quantiles to use.
if TRUE
, emphasised points will be positioned on top
the default colour functions, containing a list with entries for 'cat' and 'cont' variables
the colour for missing values; default is a light grey
logical, if TRUE
the palette will be reversed
the method to use for colouring by a variable, one of 'linear' or 'rank'
the overall scaling for the entire plot; values less than 1 will make the text and points smaller, while values larger than 1 will magnify everything
the scaling value for points
the scaling value for points in a dotplot. Note, this is not multiplicative with
'cex.pt'
the scaling value for the plot labels
the scaling value for the axis labels
the scaling value for the main plot title
the scaling value for text on the plot
one of 'proportional' (default) or 'emphasize'
transparency setting for points; default is 1, 0 is fully transparent
the background colour for the plot
logical to control drawing of axis grid lines
if 'grid.lines' is TRUE
, this controls the colour of them.
The default is 'default', which will choose a colour based on the value of 'bg')
the fill colour for points; default is "transparent"
the line width of lines (for joining points)
the line type of lines (for joining points)
the line width used for points; default is 2
the colour of lines used to join points
vector of up to two colours for the background of subplot labels. If only one specified, it is used for both.
the default colour for locating points
colour to use for highlighting points
the axes to add jitter to. Takes values "x"
, "y"
,
or "xy"
(default is en empty string, ""
)
the axes to add rugs to. Takes same values as jitter
a vector containing the trend lines to add to the plot. Possible values
are c("linear", "quadratic", "cubic")
the smoothing (lowess) for the points. Takes a value between 0 and 1 (the default, 0, draws no smoother)
the line type used for smoothers if trend.by = TRUE
if quantile smoothers are desired, they can be specified here as either
the quantiles to smooth over (e.g., c(0.25, 0.5, 0.75)
), or "default"
, which
uses the sample size to decide on an appropriate set of quantile smoothers
logical, if TRUE
, then a 1-1 line of equality is drawn
logical, if TRUE
, then points are joined by lines
logical, if join = TRUE
and colby
is specified, points are joined
by the specified variable
a named list of colours to be used for drawing the lines. The default is
list(linear = "blue", quadratic = "red", cubic = "green4")
a named list of line types for various types of trend lines. The default is
list(linear = 1, quadratic = 2, cubic = 3)
logical, if TRUE
, then trend lines are drawn separately for
each group specified by colby
logical, if TRUE
, the trend lines by group are given the same slope;
otherwise they are fit independently
the colour of the smoother
the colour of the line of equality
the line type of the line of equality
logical, if TRUE
, a boxplot is drawn with dotplots and histograms
the line width, colour, and fill colour for the box plot drawn
the line width, colour, and fill colour of bars in a bar plot
logical, if TRUE
bar graphs will display counts instead of percentages (the default)
logical, if TRUE
the width of bars will be proportional to the number of observations in each group (colour)
may no longer be necessary ...
the line width of comparison and confidence intervals, respectively
the colour of comparison and confidence intervals, respectively. These take a length 2 vector, where the first element is used for normal inference, while the second is used for bootstrap intervals
the type of inference added to the plot. Possible values
are c("comp", "conf")
the parameter which we obtain intervals for. For a dotplot or histogram,
this can be either "mean"
or "median"
; for bar plots it can be "proportion"
the width of confidence intervals, default 0.95 for a 95% confidence interval
logical, if TRUE
, then nonparametric bootstrap simulation is used
to obtain the intervals
the min count for barplots inference; counts less than this are ignored
the number of bootstrap simulations to perform
sample sizes over this value will use a large-sample plot variant (i.e., scatter plots will become hex plots, dot plots become histograms)
logical, if TRUE
, then the large-sample plot variance is used
the number, N, of bins to use for the scatter-grid plot, producing an N x N matrix
the number of bins to use for hexagonal binning
the style of the hexagons, one of "size" or "alpha"
logical, Pass on rounding error to nearest not-yet-drawn hexes so that rare classes get represented
the number of bins to use for the histogram
(The default NULL
uses point size to approximate dot plot)
if quant.smooth = "default"
, these sample size values are used
to determine which quantiles are drawn
used to override the default plot type. Possible values, depending on data type,
include c("scatter"|"grid"|"hex"|"dot"|"hist")
logical, if TRUE
, then the type of plot is kept consistent between different
subsets
a vector of two values used to decide whether to use all small-sample or all large-sample plots
a vector defining the x axis limits (default NULL will use the data)
a vector defining the y axis limits (default NULL will use the data)
a list of variable transformations (e.g., list(x = 'log'))
a list containing any additional features for new plots (e.g., maptype)
integer specifying optional rounding of numerical output, default NA (ignored)
integer specifying rounding for percentages (default 2)
integer specifying number of significant figured in numeric output (default 2). Ignored if round
is not NA.
an object of class inzpar.list
# arguments can be passed directly to \code{iNZightPlot} iNZightPlot(Sepal.Length, data = iris, col.pt = "red", box.col = "blue", box.fill = "green" ) # or stored and passed to it (only pars relevant to the current # plot are used) mypar <- inzpar( col.pt = "red", box.col = "blue", box.fill = "green", trend = "linear", trend.by = TRUE ) inzplot(Sepal.Length ~ Species, data = iris, inzpar = mypar) iNZightPlot(Sepal.Length, Sepal.Width, data = iris, inzpar = mypar, colby = Species )
# arguments can be passed directly to \code{iNZightPlot} iNZightPlot(Sepal.Length, data = iris, col.pt = "red", box.col = "blue", box.fill = "green" ) # or stored and passed to it (only pars relevant to the current # plot are used) mypar <- inzpar( col.pt = "red", box.col = "blue", box.fill = "green", trend = "linear", trend.by = TRUE ) inzplot(Sepal.Length ~ Species, data = iris, inzpar = mypar) iNZightPlot(Sepal.Length, Sepal.Width, data = iris, inzpar = mypar, colby = Species )
A generic function used to plot objects within the iNZight ecosystem.
inzplot(x, ..., env = parent.frame()) ## S3 method for class 'formula' inzplot(x, data = NULL, design = NULL, ..., env = parent.frame())
inzplot(x, ..., env = parent.frame()) ## S3 method for class 'formula' inzplot(x, data = NULL, design = NULL, ..., env = parent.frame())
x |
A formula in the form of |
... |
Any arguments to pass to |
env |
the parent environment to pass to the plot function |
data |
Dataset to plotq |
design |
A survey design to use |
inzplot
is a simple wrapper around the iNZightPlot
function.
There are four options for the formula passed in:
y
will produce a plot of the single variable y
.
y ~ x
will produce a plot of y
against x
.
y ~ x | g1
will produce a plot of y
against x
subset by g1
.
y ~ x | g1 + g2
will produce a plot of y
against x
subset by g1
and g2
.
The output depends on the type of input, but is usually called for the side-effect of producing a plot.
An inzightplotoutput
object, which contains the information
displayed in the plot
iNZightPlot
data("CO2") inzplot(~uptake, data = CO2) inzplot(uptake ~ Treatment, data = CO2) inzplot(uptake ~ Treatment | Type, data = CO2) inzplot(uptake ~ Treatment | Type, data = CO2, g1.level = "Quebec" )
data("CO2") inzplot(~uptake, data = CO2) inzplot(uptake ~ Treatment, data = CO2) inzplot(uptake ~ Treatment | Type, data = CO2) inzplot(uptake ~ Treatment | Type, data = CO2, g1.level = "Quebec" )
A generic function used to summarize objects within the iNZight ecosystem.
inzsummary(x, ..., env = parent.frame()) ## S3 method for class 'formula' inzsummary(x, data = NULL, design = NULL, ..., env = parent.frame())
inzsummary(x, ..., env = parent.frame()) ## S3 method for class 'formula' inzsummary(x, data = NULL, design = NULL, ..., env = parent.frame())
x |
An object |
... |
additional arguments for methods |
env |
an environment to evaluate things |
data |
Dataset to plotq |
design |
A survey design to use |
The output depends on the type of input, and consists of a summary object with a print
method.
inzsummary(formula)
: Wrapper for getPlotSummary to obtain summary information about a plot
Mend a plot call based on valid parameters
mend_call(call, data, design_name, plot)
mend_call(call, data, design_name, plot)
call |
a plot call string, or expression |
data |
the dataset |
design_name |
name of the design, if any |
plot |
the result of |
a plot call with extraneous arguments removed
The default action is for the URL to be 'printed' (opened) in the browser, unless 'viewer' is specified as something else. If 'viewer = NULL', then the URL is printed as a character string.
## S3 method for class 'inzHTML' print(x, viewer = getOption("viewer", utils::browseURL), ...)
## S3 method for class 'inzHTML' print(x, viewer = getOption("viewer", utils::browseURL), ...)
x |
a URL that will be printed |
viewer |
the viewing function to use to display the URL |
... |
additional arguments |
NULL (it's a print function, after all)
Based off Microdata Output Guide 2020 v5-1
snz_privacy_controls(type = c("survey"), weighted = type == "survey", ...)
snz_privacy_controls(type = c("survey"), weighted = type == "survey", ...)
type |
the type of data, used to specify the correct rules. Currently only survey (4.0.1) data is supported. |
weighted |
logical indicating if the results are a weighted survey design or not. |
... |
additional arguments, used to override defaults |
a list of privacy control rules