[R] Simple Error Bar

Jim Lemon jim at bitwrit.com.au
Fri Dec 6 08:26:45 CET 2013


On 12/06/2013 04:16 PM, mohan.radhakrishnan at polarisft.com wrote:
> Hi,
>                Basic question with basic code.   I am simulating a set of
> 'y' values for a standard 'x' value measurement. So here the error bars
> are very long because the
> number of samples are very small. Is that correct ? I am plotting the mean
> of 'y' on the 'y' axis.
>
>
> Thanks,
> Mohan
>
> x<- data.frame(c(5,10,15,20,25,30,35,40,50,60))
>   colnames(x)<- c("x")
>
>   y<- sample(5:60,10,replace=T)
>   y1<- sample(5:60,10,replace=T)
>   y2<- sample(5:60,10,replace=T)
>   y3<- sample(5:60,10,replace=T)
>   y4<- sample(5:60,10,replace=T)
>
>   z<- data.frame(cbind(x,y,y1,y2,y3,y4))
>   z$mean<- apply(z[,c(2,3,4,5,6)],2,mean)
>   z$sd<- apply(z[,c(2,3,4,5,6)],2,sd)
>   z$se<- z$sd / sqrt(5)
>
>
Hi Mohan,
As your samples seem to follow a discrete uniform distribution, the 
standard deviation is approximately the number of integers in the range 
(56) divided by the number of observations (10).

Jim



More information about the R-help mailing list