-
Notifications
You must be signed in to change notification settings - Fork 0
/
pairs.qmd
48 lines (35 loc) · 1.17 KB
/
pairs.qmd
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
```{r setup, include = FALSE}
source("global.R")
```
# Pairs plots {#sec-pairs}
## General pairs plot
This is a simple wrapper around `GGally::ggpairs` with some customizations that
have been developed internally at MetrumRG over the years.
```{r}
#| fig-width: 5
#| fig-height: 5
cols <- c("WT//Weight", "ALB//Albumin", "SCR//Serum creat")
pairs_plot(id, cols)
```
One customization we've added is the annotation on the upper triangle, which
is the `complete.obs` correlation between `x` and `y` along with the number
of observations.
## ETA pairs plots
There is also a function called `eta_pairs()` that is identical to the
`pairs_plot()` function. This might be helpful to remember the function name
but there is no difference in functionality between `eta_pairs()` and
`pairs_plot()`.
## Customized lower triangle
Pass a function that customizes the scatter plots on the lower triangle. This
function should accept a gg object and add a geom to it
```{r}
my_lower <- function(p) {
p + geom_point(aes(color = STUDYc)) +
geom_smooth(se = FALSE, color = "black")
}
```
```{r}
#| fig-width: 5
#| fig-height: 5
pairs_plot(id, c("WT", "ALB"), lower_plot = my_lower)
```