-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathREADME.Rmd
83 lines (56 loc) · 3.44 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
70
71
72
73
74
75
76
77
78
79
80
81
---
output: github_document
---
<!-- README.md is generated from README.Rmd. Please edit that file -->
```{r, include = FALSE}
knitr::opts_chunk$set(
collapse = TRUE,
comment = "#>",
fig.path = "man/figures/README-",
out.width = "100%",
eval = TRUE
)
```
# CassowaryR <a href="https://numbats.github.io/cassowaryr/"><img src="man/figures/logo.png" align="right" height="139" /></a>
<!-- badges: start -->
[![Codecov test coverage](https://codecov.io/gh/numbats/cassowaryr/branch/master/graph/badge.svg)](https://app.codecov.io/gh/numbats/cassowaryr?branch=master)
[![R-CMD-check](https://github.com/numbats/cassowaryr/workflows/R-CMD-check/badge.svg)](https://github.com/numbats/cassowaryr/actions)
<!-- badges: end -->
The `cassowaryr` package provides functions to compute scagnostics on pairs of numeric variables in a data set.
The term __scagnostics__ refers to scatter plot diagnostics, originally described by John and Paul Tukey. This is a collection of techniques for automatically extracting interesting visual features from pairs of variables. This package is an implementation of graph theoretic scagnostics developed by Wilkinson, Anand, and Grossman (2005) in pure R.
## Installation
The package can be installed from CRAN using
> ```install.packages("cassowaryr")```
and from GitHub using
> ```remotes::install_github("numbats/cassowaryr")```
to install the development version.
## Examples
```{r, sc}
library(cassowaryr)
library(dplyr)
# A single scagnostic on two vectors
data("anscombe_tidy")
sc_outlying(anscombe$x1, anscombe$y1)
```
```{r calc_scags}
data("datasaurus_dozen")
datasaurus_dozen %>%
dplyr::group_by(dataset)%>%
dplyr::summarise(calc_scags(x, y, scags=c("clumpy2", "monotonic")))
```
## About the name
CAlculate Scagnostics on Scatterplots Over Wads of Associated Real numberYs in R
## About the calculations
### Graph-based measures
A 2-d scatter plot can be represented by a combination of three graphs
which are computed directly from the Delauney-Voroni tesselation.
1. A __minimum spanning tree__ weighted by the lengths of the Delauney triangles
2. The __convex hull__ of the points i.e. the outer segments of the triangulation
3. The __alpha hull__ (also called concave hull) i.e. formed by connect the outer edges of triangles that are enclosed within a ball of radius _alpha_.
All graph based scagnostic measures are computed with respect to these three graphs.
Prior to graph construction decisions must be made about filtering outliers (done with respect to the distribution of edge lengths in the triangulation) and thinning the size of the graphs by performing binning (for computational speed). For the moment we can forge ahead without these but it is worth keeping in mind that the package needs to be flexible enough to include them.
There are also opportunities to experiment with the preprocessing here.
Two MST measures "clumpy" and "outlying" are known to cause problems.
As all the graph based measures rely on the triangulation, they could be computed lazily. More concretely, if you are only interested in computing "skinny" you don't need to compute the spanning tree. If you computed "skinny" but wanted to then compute "convex" you shouldn't need to reconstruct the alpha-hull and so on... To begin let's not worry about that and focus on implementations of each measure.
### Association-based measures
These are computed directly from the 2-d point clouds, and do not need to be constructed from the graph.