| Type: | Package | 
| Title: | Displaying Changes Between Two Points Using Dumbbell Plots | 
| Version: | 0.1 | 
| Author: | Foo Cheung | 
| Maintainer: | Foo Cheung <foocheung@yahoo.com> | 
| Description: | Creates a Dumbbell Plot. | 
| License: | MIT + file LICENSE | 
| Encoding: | UTF-8 | 
| LazyData: | true | 
| Imports: | dplyr,tidyr, tidyverse, ggplot2, rlang, utils, data.table, rstatix | 
| URL: | https://github.com/foocheung2/dumbbell | 
| NeedsCompilation: | no | 
| Packaged: | 2021-02-23 23:57:26 UTC; cheungf | 
| RoxygenNote: | 7.1.1 | 
| Collate: | 'global.R' 'dumbbell.R' | 
| Suggests: | knitr, rmarkdown | 
| VignetteBuilder: | knitr | 
| Repository: | CRAN | 
| Date/Publication: | 2021-02-25 09:10:02 UTC | 
Dumbbell Plot
Description
Draws a Dumbbell Plot, essentially a dot plot with two series of data.
Usage
dumbbell(
  xdf,
  id,
  key,
  column1,
  column2,
  lab1,
  lab2,
  title,
  pointsize,
  textsize,
  segsize,
  expandx,
  expandy,
  p_col1,
  p_col2,
  leg,
  col_seg1,
  col_seg2,
  col_lab1,
  col_lab2,
  pt_alpha,
  arrow_size,
  arrow,
  pt_val,
  delt,
  pval
)
Arguments
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   | 
Value
Dumbbell plot
Author(s)
Foo Cheung, foocheung@yahoo.com
Examples
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")