I've figured out how to draw a nice lorenz curve that is adjusted to frequency of observations. I use the ineq
package, version 02.13.
install.packages("ineq")
library(ineq)
foo <- c(3,5,8,2,1,8,2,9)
foo_n <- c(17,23,30,88,22,7,1,3)
Lc.foo <- Lc(foo, n = foo_n) # n adjusts for the frequency of observations
plot(Lc.foo, general = F, col = "darkred") # 'general = F' is supposed to prevent general line from being plotted
The result is the following plot:
simple lorenz curve plot
How can I get rid of the line indicating the perfect equity (aka the straight black line connecting 0|0 and 1|1)? It's more or less the opposite of that question.
Documentation says: Set general = F
. As seen in the code above, I've done that, but it has no effect.
For other reasons, I had to fiddle around with my RTools
installation and now I get a warning each time when I install ineq
. Might a disfunctional RTools
be the culprit here? Could any of you replicate the case within an out-of-the-box RTools
environment?
Concerning alternative packages: I've already tried gglorenz, but there I don't have a simple way of adjusting for the number of observations. Anyway, I'd be grateful for hints towards other packages that allow for this adjustment.
Thx!
edit:
I've found a way omitting this problem. It's not as neat as the solution proposed by Rui below, but it works:
Just insert this piece of code below plot(...
:
#add a white abline that covers the general line that you can't control
lines(x = c(0,1), y = c(0,1), lwd=2, col="white")
If desired, you can now plot an abline with color and style of your choice:
# add a dotted grey line that smoothly indicates equity line
lines(x = c(0,1), y = c(0,1), lwd=1, col="grey40", lty = 3)
These lines cover the Lorenz curves around the positions 0|0 and 1|1 though. For me that's no problem as I have several curves in one plot. The 2nd curve then covers up the white and grey lines. If you wanna plot one curve, better go with Rui's approach.
question from:
https://stackoverflow.com/questions/65933370/lorenz-curve-in-r-remove-general-line-ineq-package-02-13