LetMeSOThat4U
LetMeSOThat4U

Reputation: 6786

Display values insted of index for quintiles (R)

Quantile displays cut-off values when called on R commandline:

> quantile(cnt, probs=seq(0,0.95,0.05))
 0%  5% 10% 15% 20% 25% 30% 35% 40% 45% 50% 55% 60% 65% 70% 75% 80% 85% 90% 95% 
  0   1   1   1   1   1   1   1   1   2   2   2   2   2   3   4   4   5   7  11 

However,

plot(quantile(cnt, probs=seq(0,0.95,0.05)))

displays quintile index (5,10,15,20) instead of cut-off values on X axis.

How do I display cut-off values for quantiles on X axis on the graph?

Upvotes: 1

Views: 220

Answers (1)

Mike Wise
Mike Wise

Reputation: 22827

The question is not all that clear, but after looking at it awhile, I think it is about getting the right scale on the x-axis. I made up some similar data.

And then I think you are getting something like this:

cnt <- trunc(12*runif(1000)^4)+1
plot(quantile(cnt, probs=seq(0,0.95,0.05)))

which yields this plot: - (note the 5,10,15,20 - index values on the X-axis)

enter image description here

But what you want is something like this:

cnt <- trunc(12*runif(1000)^4)+1
s <- seq(0,0.95,0.05)
plot(s,quantile(cnt, probs=s))

Which yields this - quantile values on the X-axis :

enter image description here

Upvotes: 1

Related Questions