Description Usage Arguments Value Author(s) Examples
Draws a Dumbbell Plot, essentially a dot plot with two series of data.
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 |
xdf |
data a data frame, |
id |
is the name of the column containing the id variable which will label the y axis eg(subject1,subject2 etc) eg |
key |
is the name of the column containing the key variable telling us which measure we use in each row eg |
column1, column2 |
first and second series of data eg |
lab1, lab2 |
labels for data series eg |
title |
Adds title to the plot eg |
pointsize |
Adds pointsize to the points eg |
textsize |
numeric value specifying the text size eg |
segsize |
numeric value specifying the segment width eg |
expandx |
Add space to the both ends of the x axis eg |
expandy |
Add space to the both ends of the y axis eg |
p_col1, p_col2 |
colors for start and end points eg |
leg |
Add legend title |
col_seg1, col_seg2 |
Adds a color to each arrow in each direction eg |
col_lab1, col_lab2 |
color text below each dumbell eg |
pt_alpha |
Add transparentcy to points |
arrow_size |
Add size to arrows |
arrow |
Adds an arrow to one end of the dumbbell eg |
pt_val |
Add option to show the point values eg |
delt |
Add a delta column to the plot eg |
pval |
Adds pvalue to the facet label, from using a wilcox paired test eg |
Dumbbell plot
Foo Cheung, foocheung@yahoo.com
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 | library(tidyverse)
library(ggplot2)
library(rlang)
library(utils)
library(data.table)
library(dumbbell)
## create data
z<-data.frame(Group = c(rep("A",20),rep("B",20)),
# Subject = c(paste("sub_",1:20,sep=""),paste("sub_",1:20,sep="")),
Subject = c(paste(1:20,sep=""),paste(1:20,sep="")),
result = c(sample(1:100000, 40, replace=TRUE)),
analysis = c(rep("a",10),rep("b",10) ,rep("b",10),rep("a",10) )
)
b<-z %>% filter(Group == 'A')
c<-z %>% filter(Group == 'B')
d<-merge(b,c, by.x="Subject", by.y = "Subject")
e<-d %>% mutate("diff"=result.x-result.y) %>% arrange(diff)
d$Subject<-factor(d$Subject, levels = e$Subject)
## Basic plot
dumbbell(xdf=d,id= "Subject",key="analysis.x",column1 = "result.x",column2 = "result.y")
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.