我正在尝试针对正态分布绘制卡方。我收到以下错误,但不确定为什么: “在rep(value [[k]],length.out = n)中:尝试复制'closure'类型的对象”
library(tidyverse)
set.seed(10204)
mu = 0
sd = 1
norm_df <- tibble(X = seq(1, 10, 1),
Z = dnorm(x = X, mu, sd))
chi_df <- tibble(Xseq = seq(1, 10, 1),
X = dchisq(x = Xseq, df = 1))
ggplot(data = norm_df, aes(x = X)) +
geom_histogram(y = stat(density), binwidth = 1) +
geom_line(data = chi_df, aes(x = Xseq - 0.5, y = X))
我希望能够绘制出一个图,卡方是分布上的线,法线的频率计数是直方图。