Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/r/72.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 line()命令显示交叉线_R_Plot_Line - Fatal编程技术网

R line()命令显示交叉线

R line()命令显示交叉线,r,plot,line,R,Plot,Line,当我把line()添加到hist()时,我得到了无法解释的交叉线,你能告诉我为什么吗?请 x试试这个: 库(MASS) x因为行按给定值的顺序绘制:行(x[order(x)],pdf_gamma[order(x)],col=“red”) x <- rgamma(100, shape = 1, rate = 2) gamma_distr <- fitdistr(x, densfun="gamma") pdf_gamma <- dgamma(

当我把
line()
添加到
hist()
时,我得到了无法解释的交叉线,你能告诉我为什么吗?请

x试试这个:

库(MASS)

x因为
按给定值的顺序绘制:
行(x[order(x)],pdf_gamma[order(x)],col=“red”)
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")