# [R] Question about plotting related to roll-up

Wed Jun 30 18:45:17 CEST 2004

```grp  <- rep(1:5, each=3)
resp <- rnorm(15)

mu <- tapply(resp, grp, mean)
s  <- tapply(resp, grp, sd)
stopifnot( identical( names(mu), names(s) ) )

LCL <- mu - 2*s  # lower confidence limit
UCL <- mu + 2*s
Here I choose 2 as we expect 95% of the data to fall under 4 sd.

# Type 1
plot(names(mu), mu, type="l", ylim=c( min(LCL), max(UCL) ))
lines(names(mu), UCL, lty=3)
lines(names(mu), LCL, lty=3)

Your group must contain only numeric values. Otherwise, you will need to
use a numerical coding followed by mtext() with proper characters.

# Type 2
plot(names(mu), mu, type="p", ylim=c( min(LCL), max(UCL) ))
arrows( as.numeric(names(mu)), LCL, as.numeric(names(mu)), UCL, code=3,
angle=90, length=0.1 )

On Wed, 2004-06-30 at 17:33, Coburn Watson wrote:
> Hello R'ers,
>
> I have a large set of data which has many y samples for each unit x.  The data
> might look like:
>
> Seconds	Response_time
> ----------    ----------------
> 0			0.150
> 0			0.202
> 0			0.065
> 1			0.110
> 1			0.280
> 2			0.230
> 2			0.156
> 3			0.070
> 3			0.185
> 3			0.255
> 3			0.311
> 3			0.120
> 4
> .... and so on
>
> When I do a basic plot with type=l or the default of points it obviously plots
> every point.  What I would like to do is generate a line plot where the
> samples for each second are rolled up, averged and plotted with a bar which
> represents either std dev or some other aspect of variance.  Can someone
> recommend a plotting mechanism to achieve this?  I have adding lines using
> some of the smoothing functions but seem unable to remove the original plot
> line which is drawn (is there a way to just plot the data as feed through the
> smoothing function without the original data?).
>
>
> Thanks,
>
> Coburn Watson
> Software Performance Engineering
> DST Innovis
>
> ______________________________________________
> R-help at stat.math.ethz.ch mailing list
> https://www.stat.math.ethz.ch/mailman/listinfo/r-help