[R] Draw a circle at the end of a line

jim holtman jholtman at gmail.com
Thu Oct 12 22:55:12 CEST 2006


try this:

xx<-seq(0,3.5,by=0.01)
x.breaks <- seq(0, max(ceiling(xx)), .5)
# use 'cut' to split the data and create labels for your increments
x.1 <- cut(xx, breaks=x.breaks, labels=seq(.1, by=.2,
length=length(x.breaks)-1),
  include.lowest=TRUE)
plot(as.numeric(as.character(x.1)))
# get indices of each step and use last point for the circle
x.ind <- split(seq(along=x.1), x.1)
for (i in names(x.ind)){
   if (length(x.ind[[i]]) > 0)  # make sure there is data
      points(tail(x.ind[[i]],n=1),as.numeric(i), pch=21, cex=5, col='red')
}




On 10/12/06, Jue.Wang2 at sanofi-aventis.com <Jue.Wang2 at sanofi-aventis.com> wrote:
> I have a plot of cumulative distribution function which is a step function,
> I'd like to put a cycle at the right end of each line to indicate that the value here is not available in this line.
>
> How can I do that?
>
> Thank you.
>
>
> cdf<-function(x){
> do.call("rbind",lapply(1:nrow(as.matrix(x)), function(i){
> a<-x[i]
> if (a<0.5){b=0.1}
> else if (a<1){b=0.3}
> else if (a<1.5){b=0.5}
> else if (a<2.5){b=0.7}
> else if (a<3){b=0.9}
> else b<-1
> }))}
>
> xx<-seq(0,3.5,by=0.01)
> pp<-cdf(xx)
>
> plot(xx,pp)
>
>
> Jue Wang, Biostatistician
> Contracted Position for Preclinical & Research Biostatistics
> PrO Unlimited
> (908) 231-3022
>
> ______________________________________________
> R-help at stat.math.ethz.ch 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.
>


-- 
Jim Holtman
Cincinnati, OH
+1 513 646 9390

What is the problem you are trying to solve?



More information about the R-help mailing list