R中的绘制密度 [英] Plotting densities in R
问题描述
因此,我正在绘制密度(直方图).例如:
So, I am plotting densities (histograms). For example:
d <- density(table[table$position==2,]$rt)
但是,我想在同一图上绘制多个密度.例如,我也想绘制
But, I want to plot multiple densities on the same plot. For instance, I also want to plot
density(table[table$position==3,]$rt)
density(table[table$position==4,]$rt)
density(table[table$position==5,]$rt)
此外,我想为每种密度指定中心点.
Furthermore, I want to specify the center point for each of these densities.
问这个问题的另一种方法是,如何手动将密度图移动一定数量的x单位? (例如,将所有x值增加5)
Another way to ask this question is, how can I manually shift a density plot over by a certain number of x units? (for instance, increase all x values by 5)
推荐答案
与许多R分析功能一样,保存输出是您的朋友. ?density
也是如此.
As with many R analysis functions, saving the output is your friend. So is ?density
.
foo<-density(something)
names(foo)
"x", "y" , "bw", "n" , "call" ,"data.name"
所以,
plot(foo$x+5, foo$y, t='l')
据我所知,您已经完成了.
So,
plot(foo$x+5, foo$y, t='l')
And you're done so far as I can tell.
这篇关于R中的绘制密度的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!