jjchern / gglorenz

Plotting Lorenz curves with the blessing of ggplot2
https://jjchern.github.io/gglorenz/
Other
30 stars 2 forks source link

Different Quantiles #7

Open nithinmkp opened 3 years ago

nithinmkp commented 3 years ago

Can the plot be made with different quantiles? say 20% or with 10% bins?

cortinah commented 3 years ago

I don't think gglorenz package can help you with this. But you could try something like this:

library(gglorenz) data("billionaires")

q <- quantile(billionaires$TNW, seq(0, 1, 0.1)) q <- as.data.frame(q) q$n <- as.numeric(sub("%","", rownames(q)))/100

q$q <- cumsum(q$q)/sum(q$q)

ggplot(q, aes(x=n,y=q)) +geom_path()

nithinmkp commented 3 years ago

Thanks Hernando for the solution. Why I preferred "gglorenz" was that I could have got the shaded region between line of equality and lorenz curve!! Is there a solution to do this too?

Thanks and Regards, Nithin

On Sat, Sep 19, 2020 at 10:48 AM Hernando Cortina notifications@github.com wrote:

I don't think gglorenz package can help you with this. But you could try something like this:

`library(gglorenz) data("billionaires")

q <- quantile(billionaires$TNW, seq(0, 1, 0.1)) q <- as.data.frame(q) q$n <- as.numeric(sub("%","", rownames(q)))/100

q$q <- cumsum(q$q)/sum(q$q)

ggplot(q, aes(x=n,y=q)) +geom_path()`

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/jjchern/gglorenz/issues/7#issuecomment-695166709, or unsubscribe https://github.com/notifications/unsubscribe-auth/APQKHSZHZX6WYSM5DKQ2AUTSGQ5LBANCNFSM4RPAM5CQ .

cortinah commented 3 years ago

ggplot(q, aes(x=n,y=q)) +geom_path() +geom_polygon()

nithinmkp commented 3 years ago

Thanks hernando :)

On Sat, Sep 19, 2020 at 7:02 PM Hernando Cortina notifications@github.com wrote:

ggplot(q, aes(x=n,y=q)) +geom_path() +geom_polygon()

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/jjchern/gglorenz/issues/7#issuecomment-695213956, or unsubscribe https://github.com/notifications/unsubscribe-auth/APQKHS4XHYINTVEEJR55O7LSGSXGTANCNFSM4RPAM5CQ .