lattice
Reproducing lattice dendrogram graph with ggplot2
EDIT From 8 August 2011 the ggdendro package is available on CRAN Note also that the dendrogram extraction function is now called dendro_data instead of cluster_data Yes, it is. But for the time being you will have to jump through a few hoops: Install the ggdendro package (available from CRAN). This package will extract the … Read more
R package lattice won’t plot if run using source()
It is in the FAQ for R — you need print() around the lattice function you call: 7.22 Why do lattice/trellis graphics not work? The most likely reason is that you forgot to tell R to display the graph. Lattice functions such as xyplot() create a graph object, but do not display it (the same … Read more
change background and text of strips associated to multiple panels in R / lattice
Here’s a clean and easily customizable solution. myStripStyle(), the function that is passed in to the strip= argument of xyplot() uses the counter variable which.panel to select colors and also the value of factor.levels for the panel that’s currently being plotted. If you want to play around with the settings, just put a browser() somewhere … Read more
Lattice: multiple plots in one window?
The ‘lattice’ package is built on the grid package and attaches its namespace when ‘lattice’ loaded. However, in order to use the grid.layout function, you need to explicitly load() pkg::grid. The other alternative, that is probably easier, is the grid.arrange function in pkg::gridExtra: install.packages(“gridExtra”) require(gridExtra) # also loads grid require(lattice) x <- seq(pi/4, 5 * … Read more
How to plot a function curve in R
I did some searching on the web, and this are some ways that I found: The easiest way is using curve without predefined function curve(x^2, from=1, to=50, , xlab=”x”, ylab=”y”) You can also use curve when you have a predfined function eq = function(x){x*x} curve(eq, from=1, to=50, xlab=”x”, ylab=”y”) If you want to use ggplot, … Read more
How to save a plot as image on the disk?
There are two closely-related questions, and an answer for each. 1. An image will be generated in future in my script, how do I save it to disk? To save a plot, you need to do the following: Open a device, using png(), bmp(), pdf() or similar Plot your model Close the device using dev.off() … Read more