Navigation:  R support >

R graphic support

PDF version of the documentation Print this Topic Previous pageReturn to chapter overviewNext page

Graphical facilities are an important and extremely versatile component of the R environment. BioUML supports R graphic component with rplot JavaScript function:

 

rplot(RObject r, String expression)

   r - RObject object;

  expression - R expression which contains R graphic commands

 

The result of rplot function is Graphic Dialog in workbench version of BioUML and new browser window with picture in Web version.

Note: prlot will not display a result in console version of BioUML.

 

Simple example

 

Draw simple graphic with random values

 

var rObject = R.rserve();                      //get RObject

rplot(rObject, "plot(density(rnorm(100)))");   //execute graphic script 

 

r-graphic-example1

 

Complex example

 

Draw 3D graphic using R preprocessor

 

r = R.rserve();                                 //get RObject

#R(rplot(r, R))                                 //start block of commands for rplot

 z <- 2 * volcano;

 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);

 fill <- matrix("green3", nr = nrow(z)-1, nc = ncol(z)-1);

 fill[ , i2 <- c(1,ncol(fill))] <- "gray"; 

 fill[i1 <- c(1,nrow(fill)) , ] <- "gray"; 

 par(mar=c(.5,.5,2.5,.5)); 

 persp(x, y, z, theta = 120, phi = 15, col = fill, scale = FALSE, axes = FALSE);  

#end                                           //end block of commands

 

r-graphic-example2