MyNixOS website logo
Description

Plotting and Comparing Means with Violin Plots.

Produces violin plots with optional nonparametric (Mann-Whitney test) and parametric (Tukey's honest significant difference) mean comparison and linear regression. This package aims to be a simple and quick visualization tool for comparing means and assessing trends of categorical factors.

violinplotter

Plotting and Comparing Means with Violin Plots

Build StatusCRANLicense
License: GPL v3

R package for generating violin plots with optional mean comparison with nonparametric Mann-Whitney test (default) or parametric Tukey's honest significant difference as well as simple linear regression. This package aims to be a simple and quick visualisation tool for comparing means and assessing trends of categorical variables.

Usage

violinplotter(formula, data=NULL, TITLE="", XLAB="", YLAB="", VIOLIN_COLOURS=c("#e0f3db", "#ccebc5", "#a8ddb5", "#7bccc4", "#4eb3d3", "#2b8cbe"), PLOT_BARS=TRUE, ERROR_BAR_COLOURS=c("#636363", "#1c9099", "#de2d26"), SHOW_SAMPLE_SIZE=FALSE, SHOW_MEANS=TRUE, CATEGORICAL=TRUE, LOGX=FALSE, LOGX_BASE=10, MANN_WHITNEY=TRUE, HSD=FALSE, ALPHA=0.05, REGRESS=FALSE)
?violinplotter ### for more information

Installation

install.packages("violinplotter")

For the development version, please download from github via:

### install the "remotes" package to install R packages from github repositories
install.packages("remotes")
### install "violinplotter" (this command also performs package update)
remotes::install_github("jeffersonfparil/violinplotter")

Examples

Simulated dataset:

library(violinplotter)
x1 = rep(rep(rep(c(1:5), each=5), times=5), times=5)
x2 = rep(rep(letters[6:10], each=5*5), times=5)
x3 = rep(letters[11:15], each=5*5*5)
y = rep(1:5, each=5*5*5) + rnorm(rep(1:5, each=5), length(x1)) ### x3 is the variable affecting y (see each=5*5*5)
data = data.frame(x1, x2, x3, y)
OUT_1 = violinplotter(formula=y ~ x1 + x2 + x3 + (x2:x3), data=data, ALPHA=0.05)
OUT_2 = violinplotter(formula=y ~ x1 + x2 + x3 + (x2:x3), data=data, ALPHA=0.001)
OUT_3 = violinplotter(formula=y ~ x1 + x2 + x3 + (x2:x3), data=data, CATEGORICAL=c(F,T,T,T), LOGX=c(T,F,F,F), LOGX_BASE=c(2,1,1,1), REGRESS=c(T,F,F,F))
OUT_4 = violinplotter(formula=y ~ x1 + x2 + x3 + (x2:x3), data=data, MANN_WHITNEY=FALSE, HSD=TRUE, ALPHA=0.05)
if (sum(grepl("RColorBrewer", installed.packages()[,1]))!=0){
  OUT_4 = violinplotter(formula=y ~ x1 + x2 + x3 + (x2:x3), data=data, VIOLIN_COLOURS=list(RColorBrewer::brewer.pal(9, "Set1"), RColorBrewer::brewer.pal(9, "Spectral"), RColorBrewer::brewer.pal(9, "GnBu")))
}

Dummy dataset:

library(violinplotter)
str(dummy_data)
OUT_1 = violinplotter(formula = RESPONSE_1 ~ STRATUM*TREATMENT, data=dummy_data, CATEGORICAL=c(FALSE,TRUE,TRUE), REGRESS=c(TRUE, FALSE, FALSE), HSD=c(TRUE, TRUE, FALSE))
OUT_2 = violinplotter(formula = RESPONSE_2 ~ STRATUM*TREATMENT, data=dummy_data)
OUT_3 = supressMessages(violinplotter(formula = RESPONSE_2 ~ STRATUM + TREATMENT, data=dummy_data))

Sample output figure:

"Buying Me A Coffee"

Metadata

Version

3.0.1

License

Unknown

Platforms (77)

    Darwin
    FreeBSD
    Genode
    GHCJS
    Linux
    MMIXware
    NetBSD
    none
    OpenBSD
    Redox
    Solaris
    WASI
    Windows
Show all
  • aarch64-darwin
  • aarch64-freebsd
  • aarch64-genode
  • aarch64-linux
  • aarch64-netbsd
  • aarch64-none
  • aarch64-windows
  • aarch64_be-none
  • arm-none
  • armv5tel-linux
  • armv6l-linux
  • armv6l-netbsd
  • armv6l-none
  • armv7a-darwin
  • armv7a-linux
  • armv7a-netbsd
  • armv7l-linux
  • armv7l-netbsd
  • avr-none
  • i686-cygwin
  • i686-darwin
  • i686-freebsd
  • i686-genode
  • i686-linux
  • i686-netbsd
  • i686-none
  • i686-openbsd
  • i686-windows
  • javascript-ghcjs
  • loongarch64-linux
  • m68k-linux
  • m68k-netbsd
  • m68k-none
  • microblaze-linux
  • microblaze-none
  • microblazeel-linux
  • microblazeel-none
  • mips-linux
  • mips-none
  • mips64-linux
  • mips64-none
  • mips64el-linux
  • mipsel-linux
  • mipsel-netbsd
  • mmix-mmixware
  • msp430-none
  • or1k-none
  • powerpc-netbsd
  • powerpc-none
  • powerpc64-linux
  • powerpc64le-linux
  • powerpcle-none
  • riscv32-linux
  • riscv32-netbsd
  • riscv32-none
  • riscv64-linux
  • riscv64-netbsd
  • riscv64-none
  • rx-none
  • s390-linux
  • s390-none
  • s390x-linux
  • s390x-none
  • vc4-none
  • wasm32-wasi
  • wasm64-wasi
  • x86_64-cygwin
  • x86_64-darwin
  • x86_64-freebsd
  • x86_64-genode
  • x86_64-linux
  • x86_64-netbsd
  • x86_64-none
  • x86_64-openbsd
  • x86_64-redox
  • x86_64-solaris
  • x86_64-windows