Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/r/64.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
R ggplot具有相等总仓位计数的直方图_R_Ggplot2_Histogram - Fatal编程技术网

R ggplot具有相等总仓位计数的直方图

R ggplot具有相等总仓位计数的直方图,r,ggplot2,histogram,R,Ggplot2,Histogram,好的,我有以下数据: > head(scores1,n=15) alt cat_name disorder GS 8 V825I Poly 0.0253 29 14 D2365N Poly 0.2715 23 20 R43C VLP 0.0123 180 34 P147L VLP 0.1424 98 37 P186L VLP 0.4441 98 40 G210V V

好的,我有以下数据:

> head(scores1,n=15)
       alt cat_name disorder  GS
8    V825I     Poly   0.0253  29
14  D2365N     Poly   0.2715  23
20    R43C      VLP   0.0123 180
34   P147L      VLP   0.1424  98
37   P186L      VLP   0.4441  98
40   G210V      VLP   0.2129 109
47   P248L      Mut   0.0092  98
52   R280C      VLP   0.0483 180
55   R288K      VLB   0.0414  26
56   E292V      Mut   0.0253 121
63   A414T      Mut   0.0062  58
68   A501E      VLB   0.4725 107
78   R589Q     Poly   0.2258  43
98   H778R     Poly   0.4409  29
111  D953N      VLB   0.1048  23
> tail(scores1,n=15)
         alt cat_name disorder  GS
54219  G191V     Poly   0.0120 109
54221 R1111L      Mut   0.2364 102
54227  I125R     Poly   0.1671  97
54228  K197R     Poly   0.5456  26
54229  N220K     Poly   0.6322  94
54232  E249A     Poly   0.6661 107
54234  C301R     Poly   0.5620 180
54235  D315E     Poly   0.5992  45
54239  A666V     Poly   0.2503  64
54246 G3631R     Poly   0.8623 125
54252  R300Q     Poly   0.3807  43
54253  T343M     Poly   0.1969  81
54268    A3V     Poly   0.9593  64
54270  G117V     Poly   0.4901 109
54271  R152H      VLB   0.3529  29
我运行以下代码,以基于
GS
并按
cat_name
分组的方式存储数据,并输出一个绘图:

> ggplot (scores1, aes(GS, fill = cat_name)) + geom_histogram(binwidth = 20)
我得到下面的图:

我想要的是一个绘图,其中每个箱子的总高度标准化为1,这样我可以看到每个箱子中每个类别的相对比率,而不是计数。


想法?

有一个有效的例子是很有帮助的。你能解决这个问题,以便包括创建分数1数据(或其微型版本)的代码吗?
ggplot(钻石,aes(x=价格,y=密度,填充=清晰度))+geom_histogram()
?将数据绘制为百分比(每组的总百分比)不是可以实现同样的效果吗而不是绝对值?只需添加
position=“fill”
,就像在
geom\u栏中一样。示例:
ggplot(钻石,aes(x=价格,填充=清晰度))+geom_直方图(位置='fill',颜色='grey90')
位置='fill'
是解决方案。使用
library(scales)
scale\u y\u continuous(labels=percent\u format())
有助于使用漂亮的Axes这有一个工作示例。你能解决这个问题,以便包括创建分数1数据(或其微型版本)的代码吗?
ggplot(钻石,aes(x=价格,y=密度,填充=清晰度))+geom_histogram()
?将数据绘制为百分比(每组的总百分比)不是可以实现同样的效果吗而不是绝对值?只需添加
position=“fill”
,就像在
geom\u栏中一样。示例:
ggplot(钻石,aes(x=价格,填充=清晰度))+geom_直方图(位置='fill',颜色='grey90')
位置='fill'
是解决方案。使用
library(scales)
scale\u y\u continuous(labels=percent\u format())
有助于使用漂亮的轴