R lines() 命令显示交叉线
R lines() command shows crossed lines
当我将 lines()
添加到 hist()
时,我得到无法解释的交叉线,你能告诉我为什么吗?请
x <-
rgamma(100, shape = 1, rate = 2)
gamma_distr <-
fitdistr(x, densfun="gamma")
pdf_gamma <-
dgamma(x,
shape = gamma_distr$estimate[1],
rate = gamma_distr$estimate[2])
hist(x, 100, freq = FALSE)
lines(x = x, y = pdf_gamma, col="red")
试试这个:
library(MASS)
x <- rgamma(100, shape = 1, rate = 2)
gamma_distr <- fitdistr(x, densfun="gamma")
hist(x, 100, freq = FALSE)
curve(dgamma(x,
shape = gamma_distr$estimate[1],
rate = gamma_distr$estimate[2]), col="red", add = T)
当我将 lines()
添加到 hist()
时,我得到无法解释的交叉线,你能告诉我为什么吗?请
x <-
rgamma(100, shape = 1, rate = 2)
gamma_distr <-
fitdistr(x, densfun="gamma")
pdf_gamma <-
dgamma(x,
shape = gamma_distr$estimate[1],
rate = gamma_distr$estimate[2])
hist(x, 100, freq = FALSE)
lines(x = x, y = pdf_gamma, col="red")
试试这个:
library(MASS)
x <- rgamma(100, shape = 1, rate = 2)
gamma_distr <- fitdistr(x, densfun="gamma")
hist(x, 100, freq = FALSE)
curve(dgamma(x,
shape = gamma_distr$estimate[1],
rate = gamma_distr$estimate[2]), col="red", add = T)