在R中绘制数据集的一个%
我正在尝试在整个人群中绘制人口类别。
因此,如果我有:
df <- data.frame (population= c("a", "a", "a", "a","b", "b","b","b","c","c"),
income= c("10", "15", "12", "19","45", "42","41","43","23","23")
)
如何在密度图中绘制整个df
的“ A”的比例?如下图中所示:
编辑
我要绘制的是值A,B和C的密度。不是收入价值。在此密度图内,我只想阴影“ A”值。 基本上,我想以密度为阴影绘制来自数据帧列的值的比例。
这是我正在研究的数据集的链接。我想绘制“自雇”变量中“自雇”的值的比例。
I am trying to plot a population category inside the whole population.
So if I have:
df <- data.frame (population= c("a", "a", "a", "a","b", "b","b","b","c","c"),
income= c("10", "15", "12", "19","45", "42","41","43","23","23")
)
How can I plot the proportion of "a" from the whole df
in a density plot? Like in the following picture:
EDIT
What I am trying to plot is the density of the values a, b and c. Not the income values. And inside this density plot, I want to shadow only the 'a' values.
Basically, I want to shadow in a density plot the proportion of a value from a dataframe column.
This is the link of the dataset I am working on. I want to plot the proportion of the value "Self-Employed" in the "workclass" variable.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您的问题确实不清楚。但是也许你的意思是这样
your question is not clear indeed. But maybe you meant something like this
最后,我在 so 中找到了一个链接。 。这是我的最终代码:
Finally, I found a link in S.O.. This is my final code: