[R] Generating a vector for breaks in a histogram

Hotz, T. th50 at leicester.ac.uk
Thu Jul 3 15:16:16 CEST 2003


Dear Mick,

Have a look at ?seq - seq(1,20,length=20) should do it.

HTH

Thomas

---

Thomas Hotz
Research Associate in Medical Statistics
University of Leicester
United Kingdom

Department of Epidemiology and Public Health
22-28 Princess Road West
Leicester
LE1 6TP
Tel +44 116 252-5410
Fax +44 116 252-5423

Division of Medicine for the Elderly
Department of Medicine
The Glenfield Hospital
Leicester
LE3 9QP
Tel +44 116 256-3643
Fax +44 116 232-2976


> -----Original Message-----
> From: michael watson (IAH-C) [mailto:michael.watson at bbsrc.ac.uk]
> Sent: 03 July 2003 14:02
> To: 'r-help at stat.math.ethz.ch'
> Subject: [R] Generating a vector for breaks in a histogram
> 
> 
> Hi
> 
> I have two lots of numbers which I would like to histogram 
> using the hist() function.  For comparative reasons, I want 
> them to be on the same scale, which I can use the xlim and 
> ylim options to achieve.
> 
> However, having them on the same scale is meaningless unless 
> they have the same "breaks".  Consulting the documentation, 
> there are 4 ways of defining the number of breaks, only one 
> of which is "definite", the others merely form suggestions, 
> which I have found is not good enough.
> 
> The only definite way is to provide a vector to the hist() 
> function which is a vector of the break points for the 
> histogram.  So I need to generate a vector that contains say, 
> 500, numbers in it, equi-distance apart between a min and a max.  EG:
> 
> > myfunc(n=20,min=1,max=20) 
> 
> would provide a vector, length 20, with the numbers 1 through 
> 20 in it.
> 
> Is there a function in R that can do this?
> 
> Thanks
> Mick
> 
> ______________________________________________
> R-help at stat.math.ethz.ch mailing list
> https://www.stat.math.ethz.ch/mailman/listinfo/r-help
>




More information about the R-help mailing list