[R] problems with hist()

Guenter Tirler tirler at statistik.wu-wien.ac.at
Tue May 20 17:38:03 CEST 2003


Hi,
I try to compute the counts of a histogram of random numbers. But I
get different results depending on the limits (-10,10) or (-1000,1000)
although all numbers are in the interval (-10,10).

Have I done somthing wrong? 


> x<-rnorm(1e6)
> s1<-hist(x, br =c(-1000,-1,-0.5,0,0.5,1,1000),plot=FALSE)[[2]]
> s2<-hist(x, br =c(-10,-1,-0.5,0,0.5,1,10),plot=FALSE)[[2]]
> sum(s1)
[1] 1000000
> sum(s2)
[1] 1000000
>  s1                                                        
[1] 159035 149461 192003 191478 149789 158234
> s2
[1] 159009 149452 192004 191464 149805 158266

Thanks
Günter




More information about the R-help mailing list