-
Notifications
You must be signed in to change notification settings - Fork 1
/
Readme.Rmd
70 lines (54 loc) · 2.61 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
---
author: "Joyce Robbins"
date: "`r Sys.Date()`"
output:
github_document:
keep_html: true
---
```{r setup, include=FALSE}
# DO NOT EDIT Readme.md, EDIT Readme.Rmd instead
knitr::opts_chunk$set(echo = TRUE, message=FALSE, warning=FALSE)
```
# redav
This package will eventually contain functions, data, and templates to accompany data visualization courses.
If you encounter problems or have questions, please open an [issue](https://github.com/jtr13/redav/issues) or start/contribute to a [discussion](https://github.com/jtr13/redav/discussions).
As of now, it contains two functions: `draw_biplot()` and `plot_missing()`.
There are other options for drawing biplots in the **ggplot2** framework; `ggbiplot()` in the [**ordr** package](https://github.com/corybrunson/ordr) is an excellent choice. The main contributions of `draw_biplot()` are ease of use and option to calibrate only one of the axes. Calibration calculations are performed by `calibrate()` in the [**calibrate** package](https://cran.r-project.org/web/packages/calibrate/index.html).
Currently, `draw_biplot()` takes a data frame, performs principal components analysis (PCA) on the numeric columns using `prcomp()` and draws a biplot using the first non-numeric column as labels for the principal component scores (points). Additional options besides PCA may be added in the future.
`plot_missing()` was designed as a replacement for `extracat::visna()` which is no longer available on CRAN. It has improved labeling and the option to label axes as percents or numbers.
```{r, eval=FALSE, echo=FALSE}
## Installation
# This package is not on CRAN. Install with:
remotes::install_github("jtr13/redav")
```
## Examples
### `draw_biplot()`
```{r, fig.width = 8, dev='svg'}
library(redav)
swiss$country <- rownames(swiss)
draw_biplot(swiss)
draw_biplot(attitude)
draw_biplot(attitude, key_axis = "raises") +
labs(title = "The Chatterjee-Price Attitude Data",
subtitle = "package: datasets (base R)")
s77 <- as.data.frame(state.x77)
s77$state_name <- rownames(s77)
draw_biplot(s77)
draw_biplot(s77, key_axis = "Murder", ticklab = 0:16, project = FALSE,
point_color="deepskyblue3") + theme_classic()
draw_biplot(s77, mult = 1)
draw_biplot(s77, points = FALSE)
```
### `plot_missing()`
```{r, fig.height=4, fig.width=7, dev='svg'}
library(redav)
data(CHAIN, package = "mi")
plot_missing(CHAIN)
plot_missing(CHAIN, percent = FALSE)
plot_missing(CHAIN, max_rows = 4)
plot_missing(CHAIN, max_cols = 3)
plot_missing(CHAIN, num_char = 5)
plot_missing(CHAIN, max_rows = 4, max_cols = 3, num_char = 5, percent = FALSE)
plot_missing(mtcars)
```
*Rendered from* `Readme.Rmd`.