[R] xlim with barplot

peter dalgaard pdalgd at gmail.com
Mon Sep 23 09:00:33 CEST 2013


On Sep 23, 2013, at 05:43 , Jim Lemon wrote:
> 
> barplot(tabulate(x,nbins=85)[35:85])
> barplot(tabulate(y,nbins=85)[35:85])
> 
> This is an underhanded trick to line up the bars as I think you want them.

Not all that underhanded! table() with numeric vectors _will_ skip values not present in data, which is usually not desirable if the magnitude of the values matters. It gets a bit awkward if there are nonpositive (or very large) values, though. A better solution could be table(factor(x, levels=35:85)).

-- 
Peter Dalgaard, Professor,
Center for Statistics, Copenhagen Business School
Solbjerg Plads 3, 2000 Frederiksberg, Denmark
Phone: (+45)38153501
Email: pd.mes at cbs.dk  Priv: PDalgd at gmail.com



More information about the R-help mailing list