3D deviation

How can I show a deviation of 2 attributes (features)?

I thought about sth. like this:

http://www.optimaldesign.com/ArrayMiner/Images/Gauss.jpg

Maybe it is possible to create a R snippet?

Thanks for help

maybe you mean something like this:

http://addictedtor.free.fr/graphiques/graphcode.php?graph=26

that should be doable with the rgl package, instructions can also be found on that page

nice. hat works with the R snippet.

However it doesn't work if I put my own data in it:


z <- z <- 2 * R[1:4]     #<--------- here was volcano before


x <- 10 * (1:nrow(z))   # 10 meter spacing (S to N)
y <- 10 * (1:ncol(z))   # 10 meter spacing (E to W)

z0 <- min(z) - 20
z <- rbind(z0, cbind(z0, z, z0), z0)
x <- c(min(x) - 1e-10, x, max(x) + 1e-10)
y <- c(min(y) - 1e-10, y, max(y) + 1e-10)

R<-fill <- matrix("green3", nr = nrow(z)-1, nc = ncol(z)-1)
R<-fill[ , i2 <- c(1,ncol(fill))] <- "gray"
R<-fill[i1 <- c(1,nrow(fill)) , ] <- "gray"

R<-par(bg = "slategray",mar=rep(.5,4))
R<-persp(x, y, z, theta = 135, phi = 30, col = fill, scale = FALSE,
      ltheta = -120, lphi = 15, shade = 0.65, axes = FALSE)

 

the input table is a table of integers. the error i get is:

ERROR     R View (Local)     Execute failed: Execution of R script failed: Calls: persp -> persp.default

 

I think the problem is how I put the table data in the funktion.

Got the same probs on other examples.

 

thanks for help

judging from your code, the problem seems to be in the first line:

z <- z <- 2 * R[1:4]     #<--------- here was volcano before

with R[1:4] you only select the first 4 numbers, while you probably would like to have the first 4 columns:

z<-R[,1:4]

note the comma before 1:4 selecting all lines of the table (the factor 2 is just for exaggeration)

Further, I'm not sure, what you try to do with your data. In the volcano example the table already contains the height values, i.e. volcano[[x,y]] is the height of the volcano at position (x,y). If you didn't already, you'll have to calculate that data first.

hope that helps

hm R[1:4] does the same that R[,1:4]

I think if you select all columns there is no need for a value before the comma.

I tested it with

R<-R[1:4] and R<-R[,1:4]

but I still get the error.

I want to show bivariate outliers and there factors (calculated by the local outlier factor algorithm)  but before that I want to run the function anyhow with some own data. still get this error... I also tried to save the volcano data in a file and then retried to put it in the R snippet.

For example I have a data structure with 5 columns and 5 rows with integer values.

I read it in in KNIME and put that structure to the plot by

z <-  R[,1:5] 

but I get the same error again:


ERROR     R View (Local)     Execute failed: Execution of R script failed: Calls: persp -> persp.default

Would be nice if you try it out and send me an example codeline?

 

thanks a lot!

you're right, its a good idea to try it directly in Knime

this is a (at least for me) working example:

library(rgl)
z <- as.matrix(R[1:19])
x <- 10 * (1:nrow(z))  
y <- 10 * (1:ncol(z))  

z0 <- min(z) - 20
z <- rbind(z0, cbind(z0, z, z0), z0)
x <- c(min(x) - 1e-10, x, max(x) + 1e-10)
y <- c(min(y) - 1e-10, y, max(y) + 1e-10)
persp(x, y, z)

I think the problem was that persp() doesn't like z to be a data.frame but assumes a matrix in this place.

This also explains the comma confusion: R[1:19] works with a data frame (my example has 19 cols of doubles) but does something completely different on a matrix.

great. now it works! thanks a lot!

 

z <-  as.matrix(R[1:7])    #<--------- here was volcano before

x <- 10 * (1:nrow(z))   # 10 meter spacing (S to N)
y <- 10 * (1:ncol(z))   # 10 meter spacing (E to W)

z0 <- min(z) - 20
z <- rbind(z0, cbind(z0, z, z0), z0)
x <- c(min(x) - 1e-10, x, max(x) + 1e-10)
y <- c(min(y) - 1e-10, y, max(y) + 1e-10)

R<-fill <- matrix("green3", nr = nrow(z)-1, nc = ncol(z)-1)
R<-fill[ , i2 <- c(1,ncol(fill))] <- "gray"
R<-fill[i1 <- c(1,nrow(fill)) , ] <- "gray"

R<-par(bg = "slategray",mar=rep(.5,4))
R<-persp(x, y, z, theta = 135, phi = 30, col = fill, scale = FALSE,
      ltheta = -120, lphi = 15, shade = 0.65, axes = TRUE)

 

what I have now is a table with 3 columns:

attribute a, attribute b, attribute x

I wonder how to transform this table in a table where a and b are the indices, running from min(a) to max(a) and min(b) to max(b) and x is the value, so that x can be adressed by  X(a,b) so that I can use it as input for the plot.