I wanted to do a simple plot: Death Rate vs Clinical Site, and then draw a confidence interval of Death Rate at each clinical site, which is a factor variable with 100 levels. I used the following code: plot(Site, Rate, col="red", type="o") However, the graph was a short line at each site instead of points, and the color was not red at all. Seem to me for factor variable all options are not working ! Could anybody help me on how to draw points at each site, with specific color? if possible, how to further draw confidence interval at each site? I appreciate! -- View this message in context: http://n4.nabble.com/Plot-with-a-factor-variable-which-has-large-values-tp974321p974321.html Sent from the R help mailing list archive at Nabble.com.
On 12/18/2009 06:42 AM, changzhu wrote:> I wanted to do a simple plot: Death Rate vs Clinical Site, and then draw a > confidence interval of Death Rate at each clinical site, which is a factor > variable with 100 levels. I used the following code: > > plot(Site, Rate, col="red", type="o") > > However, the graph was a short line at each site instead of points, and the > color was not red at all. Seem to me for factor variable all options are not > working ! Could anybody help me on how to draw points at each site, with > specific color? if possible, how to further draw confidence interval at each > site? >Hi Changzu, Since I don't have Site or Rate, I'll have to be imaginative: Site<-paste(sample(LETTERS,100,TRUE), sample(letters,100,TRUE),sep="") SiteOrder<-order(Site) Rate<-runif(100) plot(as.numeric(factor(Site))[SiteOrder], Rate[SiteOrder],col="red",type="o") Having performed that chicanery, I feel justified in telling you to use the dispersion function in the plotrix package for the CIs, although there are many other similar functions. Jim
Possibly Parallel Threads
- RODBC and NULL values
- adding vertical segments to an xyplot in lattice
- [OT] Survival and Function as co-primary endpoints in clinical trials. How to simulate in R ?
- R and SAS Statistical position open with Large Pharmaceutical in New Jersey
- New SAS and R programming position with large Pharmaceutical in NJ