Package 'plotrr'

Title: Making Visual Exploratory Data Analysis with Nested Data Easier
Description: Provides tools for visual exploratory data analysis with nested data. Includes functions for creating bivariate plots, dot plots, histograms, and violin plots for each group or unit in nested data. Methods are described in Crabtree and Nelson (2017) "Plotrr: Functions for making visual exploratory data analysis with nested data easier" <doi:10.21105/joss.00190>.
Authors: Charles Crabtree [aut, cre], Michael J. Nelson [aut]
Maintainer: Charles Crabtree <charles.crabtree@monash.edu>
License: MIT + file LICENSE
Version: 1.0.2
Built: 2026-10-01 14:26:41 UTC
Source: https://github.com/lobsterbush/plotrr

Help Index


Plot two variables within each group

Description

Draws a scatterplot with a smooth curve for each group. Use it to see how the relationship varies across groups.

Usage

bivarplots(x, y, group, data)

Arguments

x

The name of the x column, as a string.

y

The name of the y column, as a string.

group

The name of the grouping column, as a string.

data

A data frame.

Value

Prints one plot per group. The function returns NULL invisibly.

Author(s)

Charles Crabtree charles.crabtree@monash.edu

Examples

a <- runif(1000, min = 0, max = 1)
b <- a + rnorm(1000, mean = 0, sd = 1)
c <- rep(c(1:10), times = 100)
data <- data.frame(a, b, c)
bivarplots("a", "b", "c", data)

Draw a scatterplot with marginal rugs

Description

Draws a scatterplot and adds marks along each axis at the observed values.

Usage

bivarrugplot(x, y, data)

Arguments

x

The name of the x column, as a string.

y

The name of the y column, as a string.

data

A data frame.

Value

Prints the plot and returns the ggplot object invisibly.

Author(s)

Charles Crabtree charles.crabtree@monash.edu

Examples

a <- runif(1000, min = 0, max = 1)
b <- a + rnorm(1000, mean = 0, sd = 1)
data <- data.frame(a, b)
bivarrugplot("a", "b", data)

Clear the console display

Description

Prints a form-feed character. Whether this clears the display depends on your console.

Usage

clear(...)

Arguments

...

An unused argument.

Value

No return value (called for side effect of printing a form feed character to the console, which visually clears the R terminal). Returns NULL invisibly.

Author(s)

Charles Crabtree charles.crabtree@monash.edu

Examples

clear()

Draw a dot plot for each group

Description

Draws the distribution of x separately for each group.

Usage

dotplots(x, y, group, data, n)

Arguments

x

The name of the x column, as a string.

y

Kept for compatibility; this function doesn't use it.

group

The name of the grouping column, as a string.

data

A data frame.

n

Sets the bin width to 1/n. Try a few values to find a useful level of detail.

Value

Prints one dot plot per group. The function returns NULL invisibly.

Author(s)

Charles Crabtree charles.crabtree@monash.edu

Examples

a <- runif(1000, min = 0, max = 1)
b <- a + rnorm(1000, mean = 0, sd = 1)
c <- rep(c(1:10), times = 100)
data <- data.frame(a, b, c)
dotplots("a", "b", "c", data, 20)

Draw a histogram for each group

Description

Draws the distribution of x separately for each group.

Usage

histplots(x, y, group, data, n)

Arguments

x

The name of the x column, as a string.

y

Kept for compatibility; this function doesn't use it.

group

The name of the grouping column, as a string.

data

A data frame.

n

The number of bins.

Value

Prints one histogram per group. The function returns NULL invisibly.

Author(s)

Charles Crabtree charles.crabtree@monash.edu

Examples

a <- runif(1000, min = 0, max = 1)
b <- a + rnorm(1000, mean = 0, sd = 1)
c <- rep(c(1:10), times = 100)
data <- data.frame(a, b, c)
histplots("a", "b", "c", data, 5)

Count distinct non-missing values

Description

Count distinct non-missing values.

Usage

lengthunique(x)

Arguments

x

A vector.

Value

The number of distinct values after removing missing values.

Author(s)

Charles Crabtree charles.crabtree@monash.edu

Examples

x <- rep(c(1:10), 10)
lengthunique(x)

Convert numeric factor labels to numbers

Description

Convert numeric factor labels to numbers.

Usage

makefacnum(x)

Arguments

x

A vector.

Value

A numeric vector.

Author(s)

Charles Crabtree charles.crabtree@monash.edu

Examples

x <- c("1", "2", "3")
x <- as.factor(x)
x
x <- makefacnum(x)
x
is.numeric(x)

Draw violin plots within each group

Description

Draws the distribution of y across values of x, separately for each group.

Usage

violinplots(x, y, group, data)

Arguments

x

The name of the x column, as a string.

y

The name of the y column, as a string.

group

The name of the grouping column, as a string.

data

A data frame.

Value

Prints one plot per group. The function returns NULL invisibly.

Author(s)

Charles Crabtree charles.crabtree@monash.edu

Examples

a <- runif(1000, min = 0, max = 1)
b <- a + rnorm(1000, mean = 0, sd = 1)
c <- rep(c(1:10), times = 100)
data <- data.frame(a, b, c)
violinplots("a", "b", "c", data)