knitr::opts_chunk$set( collapse = TRUE, comment = "#>", fig.path = "man/figures/README-", out.width = "100%" )
This is a short summary of datavis
' functionality. For a comprehensive guide aimed towards programming beginners, check the handbook Data visualization with the 'datavis' R package. For a full description of the datavis
functions, check their help documentation in pdf form or by browsing the package after installation.
The goal of datavis
is to simplify the creation, annotation and export of bar plots and box plots of publication-grade quality. It is meant for academic researchers of any programming experience - newcomers and programming experts alike.
To a large extent, datavis
wraps around the well-known ggplot2
package, but specializes in very specific plots (dodged bar and box plots based on sample distributions), aiming to increase efficiency in handling these plots.
Using the datavis
functions, you can easily perform the following tasks with very few lines of code:
Create bar/box plots with summary statistics:
arithmetic or geometric mean
plus/minus corresponding standard deviation, or custom, user-calculated error measure
optionally, individual data points
Customize plots aesthetically.
Annotate plots with custom text above bars/boxes.
Export plots in various formats for any purpose.
You can install datavis
from GitHub by executing the following lines in the R console:
install.packages("devtools") devtools::install_github("dimitriskokoretsis/datavis")
The following example demonstrates the use of datavis
functions to create, annotate and export a bar plot.
# Data import using the fread function of the data.table package demo.data.1 <- data.table::fread("guide/demo_data/demo_data_1.csv") knitr::kable(demo.data.1)
# Loading of datavis package library(datavis) # Creation of bar plot with the bar_point_plot function of datavis # See function's help documentation for more information plot.1 <- demo.data.1 |> bar_point_plot(x="factor.1", # X axis grouping based on "factor.1" field y="value", # Y axis value is "value" field color.group="factor.2", # Color grouping based on "factor.2" field x.axis="Factor 1", # Give a better title to x axis y.axis="Value", # Give a better title to y axis legend.title="Factor 2", # Give a better title to the legend jitterwidth=0.7) # Adjust horizontal jitter of individual data points plot.1
# Import of statistics data from Tukey's honest significant difference (HSD) test demo.data.1.TukeyHSD <- data.table::fread("guide/demo_data/demo_data_1_TukeyHSD.csv") knitr::kable(demo.data.1.TukeyHSD)
# Annotation of original plot with the plot_stats function of datavis # See function's help documentation for more information plot.1.TukeyHSD <- plot.1 |> plot_stats(d=demo.data.1.TukeyHSD, # The data.frame containing the labels to be plotted. labels="HSDgroups", # The name of the labels column in the supplied data.frame. position="dodge") # Positioning of labels in the X dimension. plot.1.TukeyHSD
# Export of plot in PDF, SVG, PNG and Rds formats with the plot_save function of datavis # See function's help documentation for more information plot.1.TukeyHSD |> plot_save(filepath="guide/demo_plots/plot_1_TukeyHSD", # Path to export files height=4,width=5) # Dimensions in inches
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.