Reputation: 3470
My problem is very simple.
I have to plot a data series in R, using bars. Data are contained in a vector vet
.
I've used barplot
, that plots my data from the first to the last:
barplot(vet)
, and everything was fine.
Now, on the contrary, I would like to plot not all my data, but just a part of them: from 10% to the end. How could I do this with barplot()? How could I do this with plot()?
Thanx
Upvotes: 1
Views: 1005
Reputation: 49640
It is not clear exactly what you want to do.
If you want to plot only a subset of the bars (but the whole bars) then you could just subset the data before passing it to barplot
.
If you want to plot all the bars, but only that part beyond 10% (not include 0) then you can do this by setting the ylim
argument. But it is very discouraged to do a barplot that does not include 0. You may be better off using a dotplot instead of a barplot if 0 is not meaningful.
If you want the regular plot, but want to exclude plotting outside of a given window within the plot then the clip
function may be what you want.
The gap.barplot
function from the plotrix
package may also be what you want.
Upvotes: 1
Reputation: 60462
You need to subset your data before plotting:
##Work out the 10% quantile and subset
v = vet[vet > quantile(vet, 0.1)]
Upvotes: 4