[R] any plot ?

Roger Peng rpeng at stat.ucla.edu
Mon Jan 13 04:28:03 CET 2003


You can use a few functions:  persp, contour, filled.contour, image.  Say
dens() is your density function of two variables, for example,

dens <- function(x, y) { dnorm(x) * dnorm(y) }

then you could do:

x <- seq(-3, 3, len = 40)
y <- seq(-3, 3, len = 30)
g <- expand.grid(x, y)
mat <- matrix(dens(g[,1], g[,2]), nrow = 40, ncol = 30)
image(x,y,mat)
persp(x,y,mat)
filled.contour(x,y,mat)
contour(x,y,mat)


-roger
_______________________________
UCLA Department of Statistics
rpeng at stat.ucla.edu
http://www.stat.ucla.edu/~rpeng

On Sat, 11 Jan 2003, H. Zmarrou wrote:

> 
> Dear R-ers:
> I'm sorry to disturb you, I want just ask if R can plot a given  
> complicated density function. I mean if we have the expression of the 
> density en we want to see how it's look like? and this is a density 
> with two variables thus it's a 3D plot  
> 
> Thank you very much
> Hicham Amsterdam
> 
> ______________________________________________
> R-help at stat.math.ethz.ch mailing list
> http://www.stat.math.ethz.ch/mailman/listinfo/r-help
>




More information about the R-help mailing list