首页 > 解决方案 > 普通和一样。基于因子的洛伦兹曲线给出对比结果

问题描述

我正在根据需要使用最少的可重现数据集重新发布我的问题。我正在为不平等制作洛伦兹曲线。对于普通洛伦兹曲线和基于因子的数据,相同的数据给出了不同的结果。在理解中,两者都给出了完全相反的结果。我不确定是升序还是降序数据导致了问题!有人可以帮助解决问题。并且进一步我想在一个图中为两个或多个洛伦兹曲线添加过滤器?至于刻度 1 和 2。下面是代码。正确的图形应该在 45 度线以下。请寻找解决方案。

library(gglorenz)
library(tidyverse)
ticks <-  c(1, 1, 1, 1, 1, 2, 2, 2, 2, 2)
consumption <- c(0, 3, 10, 30, 100, 10, 20, 300, 500, 1000 )
df <-  data.frame(ticks, consumption)
#plotting
df$ticks <- as.factor(df$ticks)
df %>%
  ggplot(aes(x=consumption)) +
  stat_lorenz(desc = TRUE) +
  coord_fixed() +
  geom_abline(linetype = "dashed") +
  theme_minimal() +
  hrbrthemes::scale_x_percent() +
  hrbrthemes::scale_y_percent() +
  hrbrthemes::theme_ipsum_rc() +
  labs(x = "Cumulative Percentage of the farmers",
       y = "Cumulative Percentage of Total Profits/acre",
       title = "Inequality Among farmers")
        

阴谋

对于普通 LC

ggplot(df, aes(consumption)) + 
  stat_lorenz() + 
  geom_abline(color = "grey")

阴谋

标签: rggplot2

解决方案


推荐阅读