【发布时间】:2019-10-09 06:57:43
【问题描述】:
我必须绘制这种类型的情节,但我不明白该怎么做。我必须绘制这些函数。正常:
library(tidyverse)
tibble(x = sort(rnorm(1e5)),
cumulative = cumsum(abs(x)/sum(abs(x)))/2.5) %>%
ggplot(aes(x)) +
geom_histogram(aes(y = ..density..), bins = 500)+
geom_density(color = "red")+
geom_line(aes(y = cumulative), color = "navy")+
scale_y_continuous(sec.axis = sec_axis(~.*2.5, name = "cumulative density"))
和二项式:
library(tidyverse)
set.seed(10)
tibble(x = sort(rbinom(1e5,1e5, 0.001))) %>%
ggplot(aes(x)) +
geom_histogram(aes(y = ..density..), bins = 90)+
geom_density(color = "red")
我不明白如何在 [0,1] 范围内的一个图上比较其中两个函数。也许我必须改变我的情节。但无论如何,我不知道如何在特定范围内添加两个地块。也许有人知道怎么做?
【问题讨论】:
-
range(sort(rbinom(1e5, 1e5, 0.001))) # 61 146不在 [0,1] 范围内。因此,我目前还不清楚您的问题。
标签: r