我经常使用核密度图来说明分布.这些在R中创建简单快捷,如下所示:
set.seed(1)
draws <- rnorm(100)^2
dens <- density(draws)
plot(dens)
#or in one line like this: plot(density(rnorm(100)^2))
Run Code Online (Sandbox Code Playgroud)
这给了我这个漂亮的小PDF:
我想将PDF下面的区域从第75百分位到第95百分位.使用quantile函数计算点很容易:
q75 <- quantile(draws, .75)
q95 <- quantile(draws, .95)
Run Code Online (Sandbox Code Playgroud)
但是我如何遮蔽q75和之间的区域q95?
如何在R中绘制一般的sin曲线?根据这篇文章的答案,我试过:
x <- seq(0,pi,length.out=100)
y <- sin(x)
plot(x,y,type="l")
Run Code Online (Sandbox Code Playgroud)
实际上我真正想要的是这个图表,由gnuplot以下产生:
plot sin(x) linestyle 1
Run Code Online (Sandbox Code Playgroud)
此外,我想知道为什么gnuplot即使我没有为变量赋值也会产生图形x.它是否具有预先指定的值或其他内容?