r - 普通和一样。基于因子的洛伦兹曲线给出对比结果
问题描述
我正在根据需要使用最少的可重现数据集重新发布我的问题。我正在为不平等制作洛伦兹曲线。对于普通洛伦兹曲线和基于因子的数据,相同的数据给出了不同的结果。在理解中,两者都给出了完全相反的结果。我不确定是升序还是降序数据导致了问题!有人可以帮助解决问题。并且进一步我想在一个图中为两个或多个洛伦兹曲线添加过滤器?至于刻度 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")
解决方案
推荐阅读
- cakephp - CakePHP 3 - 依靠深度关联
- firebase - 如何将 Firebase 数据导入欧盟的 Bigquery 数据集?
- google-cloud-platform - 有什么方法可以为 Google Cloud 的网络流量设置配额?
- sql-server - SQL DB Stacking 中的单个数据库开始
- android - 什么是 android-sdk 和 android-auth libs 开源许可证?
- c# - 在 Eyeshot 11 中选择 Solid3D 实体的边和顶点
- elasticsearch - ES query_string 对值的不同提升
- c# - 将列表转换为具有空值的对列表
- macros - 在宏中定义和使用函数
- javascript - Chart.js v2 中水平条形图的圆角