Levelplot - how to use it, any simple examples?

I would like to understand how levelplot works. I have almost no experience with charts and R.

What bothers me how to interpret, for example, x ~ y * z? Suppose I have a function, and I would like to show how often a certain value occurs using a 3D graph. I would therefore have x = x, y = f (x) and z = count. How to get such a simple plot using levelplot (or something else if it is not appriopriate).

Also, should I group the β€œscore” on my own - 3 columns in my data or just have 2 columns - x and f (x) and have duplicates?

Hope my question is clear, I tried to read the level-level documentation , however I could not find a tutorial that teaches the basics.

+4
source share
1 answer

The following example from the documentation is ?levelplot .

The formula z~x*y means that z is a function of x , y and the interaction between x and y . If the function were z~x+y , this would mean that z is a function of x and y , ignoring any interaction.

For more information on the formula interface, see the help for ?formula Formula.

 x <- seq(pi/4, 5 * pi, length.out = 100) y <- seq(pi/4, 5 * pi, length.out = 100) r <- as.vector(sqrt(outer(x^2, y^2, "+"))) grid <- expand.grid(x=x, y=y) grid$z <- cos(r^2) * exp(-r/(pi^3)) levelplot(z~x*y, grid, cuts = 50, scales=list(log="e"), xlab="", ylab="", main="Weird Function", sub="with log scales", colorkey = FALSE, region = TRUE) 

enter image description here

+6
source

All Articles