[R] Determine area between two density plots
Benno Pütz
puetz at mpipsykl.mpg.de
Thu Sep 23 19:04:55 CEST 2010
Am 23.Sep.2010 um 18:27 schrieb Ralf B:
> I wonder what the best way is to access those values. I am using the
> following code:
>
> x1 <- c(1,2,1,3,5,6,6,7,7,8)
> x2 <- c(1,2,1,3,5,6,5,3,8,7)
> d1 <- density(x1, na.rm = TRUE)
> d2 <- density(x2, na.rm = TRUE)
> plot(d1, lwd=3, main="bla")
> lines(d2, lty=2, lwd=3)
> d1[1]
> d1[2]
>
> The last two lines allow me to access 1000 values, but I don't know if
> this is the right approach. I also don't know why they are in two
> columns. Does density have a saver way to get to those values?
>
Do you mean
d1$x, d1$y
Benno
More information about the R-help
mailing list