Title: | Displaying Changes Between Two Points Using Dumbbell Plots |
---|---|
Description: | Creates a Dumbbell Plot. |
Authors: | Foo Cheung |
Maintainer: | Foo Cheung <[email protected]> |
License: | MIT + file LICENSE |
Version: | 0.1 |
Built: | 2024-11-26 04:22:52 UTC |
Source: | https://github.com/cran/dumbbell |
Draws a Dumbbell Plot, essentially a dot plot with two series of data.
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 )
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 )
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, [email protected]
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")
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")