-
Notifications
You must be signed in to change notification settings - Fork 0
/
README.Rmd
69 lines (53 loc) · 1.88 KB
/
README.Rmd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
---
output:
md_document:
variant: markdown_github
---
<!-- README.md is generated from README.Rmd. Please edit that file -->
```{r, echo = FALSE}
knitr::opts_chunk$set(
collapse = TRUE,
fig.path = "figs/"
)
```
## violinplot
Violin plot is a method for plotting numeric data using a
rotated/mirrored kernel density plot. Other implementations exist
(namely from [ggplot2](https://github.com/hadley/ggplot2)) that
provide extensive customization. This package provides an alternative
implementation that relies solely on base graphics, yet still provides
methods for `data.frame`, `matrix`, `list`, `numeric` vectors, and `formula`.
There is another base-graphics implementation of violin plots,
[here](https://cran.r-project.org/web/packages/vioplot/index.html),
but it hasn't been updated since 2005 and its URL link is dead.
(**Edit**: since I wrote this package, `vioplot` has been updated.
While I'm using *this* package without problem, I've had no immediate
need to compare features.)
## Installation
It's not yet submitted to CRAN, so the only option currently is to
import the development version from github:
```{r, eval = FALSE}
devtools::install_github("r2evans/violinplot")
```
## Sample Usage
```{r}
library(violinplot)
```
Anything (I think) that works for `boxplot` also works for `violinplot`:
```{r, eval = FALSE}
violinplot(mtcars$mpg, main = "Single Vector")
violinplot(mtcars$mpg, mtcars$cyl, col = 2:4,
main = "Two Vectors")
```
And, though `boxplot` already supports a "formula" method, the
`violinplot.formula` method has been extended to provide spacing
between the groups of factors:
```{r singlefactor}
violinplot(mpg ~ cyl, data = mtcars, col = 2:4,
main = "Single Factor Formula")
```
More complex formulas can be used as well:
```{r multifactor}
violinplot(mpg ~ cyl + vs, data = mtcars, col = 2:4,
main = "Multi-Factor Formula")
```