Cody Hamilton wrote:
Is there a way to create a 'bubble plot' in R?
For example, if we define the following data frame containing the level of y
observed for 5 patients at three time points:
time<-c(rep('time 1',5),rep('time 2',5),rep('time 3',5))
y<-c('a','b','c','d','a','b','c','a','d','a','a','a','b','c','d')
D<-data.frame(cbind(y,time))
I would like to display the percentage of subjects in each level of y at each
time point as a bubble whose size is proportional to the percentage of subjects
in the given level of y at the given time point. Thus, in the case of the data
frame above the plot would have the levels of y ('a','b','c','d') on the y-axis
and the levels of time ('time 1','time 2', time 3') on the x-axis with four
bubbles above each time point (e.g. the size of the bubble in the bottom left
corner of the plot would be proportional to the percentage of patients with
y='a' at time='time 1').
I am running R 2.7.1 under windows.
Regards,
-Cody
The xYplot function in the Hmisc package can do that. It may be more
elegant using ggplot2.
Frank
--
Frank E Harrell Jr Professor and Chair School of Medicine
Department of Biostatistics Vanderbilt University
______________________________________________
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.