Description Usage Arguments Author(s) Examples
Builds a custom version of geom_pointrangeh
.
1 2 3 4 5 6 7 8 9 10 11 |
mapping |
Set of aesthetic mappings created by |
data |
The data to be displayed in this layer. There are three options: If A A |
stat |
The statistical transformation to use on the data for this layer, as a string. |
position |
Position adjustment, either as a string, or the result of a call to a position adjustment function. |
... |
Other arguments passed on to |
fatten |
A multiplicative factor used to increase the size of the
middle bar in |
na.rm |
If |
show.legend |
logical. Should this layer be included in the legends?
|
inherit.aes |
If |
Ilari Scheinin
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 | library(ggplot2)
library(magrittr)
df <-
# Use built-in demo dataset
df_linear_associations %>%
# Arrange by name in order to filter the first few biomarkers for more
# than one studies
dplyr::arrange(name) %>%
# Estimate confidence intervals
dplyr::mutate(
xmin = beta - qnorm(1 - (1 - 0.95) / 2) * se,
xmax = beta + qnorm(1 - (1 - 0.95) / 2) * se
) %>%
# Select only first 30 rows (10 biomarkers)
dplyr::filter(dplyr::row_number() <= 30) %>%
# Add a logical variable for statistical significance
dplyr::mutate(filled = pvalue < 0.001)
g <-
ggplot(data = df, aes(x = beta, y = name)) +
# And point+errorbars
geom_effect(
ggplot2::aes(
xmin = xmin,
xmax = xmax,
colour = trait,
shape = trait,
filled = filled
),
position = ggstance::position_dodgev(height = 0.5)
)
print(g)
# Add custom theme, horizontal gray rectangles, vertical line to signify the
# NULL point, custom color palettes.
g <-
g +
# Add custom theme
theme_forest() +
# Add striped background
geom_stripes() +
# Add vertical line at null point
geom_vline(
xintercept = 0,
linetype = "solid",
size = 0.4,
colour = "black"
)
print(g)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.