Re: [R] How to change a venn command into a named object that can be plotted like a lattice object

2010-02-22 Thread Hrishi Mittal

George,

Unless, Venn Diagrams are produced as lattice objects, I don't think you can
save them to modify or update later on. However, if you are just looking for
a shortcut to avoid calling the plotting function again and again you could
use the recordPlot() and replayPlot() functions. Add this line to the end of
your Venn2 function definition:

return(recordPlot())

Then once you've assigned the plot to VennPlot, you can use the following
command to replot it again whenever you need it:

replayPlot(VennPlot)


-
Try  http://prettygraph.com Pretty Graph , the easiest way to make R-powered
graphs on the web.
-- 
View this message in context: 
http://n4.nabble.com/How-to-change-a-venn-command-into-a-named-object-that-can-be-plotted-like-a-lattice-object-tp1565421p1565438.html
Sent from the R help mailing list archive at Nabble.com.

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


[R] How to change a venn command into a named object that can be plotted like a lattice object

2010-02-22 Thread George Chen
Hello,

I am plotting data as a venn diagram but would like to be able to control how 
it is plotted like a lattice object.
Right now, it plots right away.  I would like to name it and then plot at will.
I thought to convert the whole thing to a PostScript file then get it back into 
R via grImport, but surely (please!) there must be a less roundabout way to do 
this.

Any help is appreciated.

Here is my code:

# Wrapper function to draw Venn diagram
Venn2 <- function(set1, set2, names, title,...){
  stopifnot( length(names) == 2)
  # Form universe as union of both sets
  universe <- sort( unique( c(set1, set2) ) )
  Counts <- matrix(0, nrow=length(universe), ncol=2)
  colnames(Counts) <- names
  for (i in 1:length(universe))  {
Counts[i,1] <- universe[i] %in% set1
Counts[i,2] <- universe[i] %in% set2
  }
  vennDiagram( vennCounts(Counts),main=title,... )
}

# How I draw the Venn diagram
Venn2(cPostArrayHitsNames,cPreArrayHitsNames,names=c("Post","Pre"),title=PatientID)

Unfortunately something like this doesn't work:
VennPlot<-Venn2(cPostArrayHitsNames,cPreArrayHitsNames,names=c("Post","Pre"),title=PatientID)

Apologies for the imprecise terminology.

Thanks.

GLC

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.