Warren.Jin@csiro.au
2005-Feb-20 21:35 UTC
[R] Ask for help on the parallel function output to a pdf file
Dear all, Could you please give me a hand on parallel function from package lattice? On the R command console, the following commands can output a parallel coordinate plot to the pdf file. library(lattice); pdf("trial.pdf"); data(iris); parallel(~iris[1:4] | Species, iris); dev.off(); However, if these commands are encapsulated into a function, the resultant pdf file is empty. For example, we define a simple function paraExam below, paraExam() may generate a pdf file which is empty from a pdf viewer. paraExam<-function(file="trial.pdf"){ library(lattice); pdf(file); data(iris); parallel(~iris[1:4] | Species, iris); dev.off(); } Please give me some tips to output parallel coordinate plots to a pdf file within a function successfully? Regards, Warren [[alternative HTML version deleted]]
Deepayan Sarkar
2005-Feb-20 22:01 UTC
[R] Ask for help on the parallel function output to a pdf file
http://cran.r-project.org/doc/FAQ/R-FAQ.html#Why-do-lattice_002ftrellis-graphics-not-work_003f On Sunday 20 February 2005 15:35, Warren.Jin at csiro.au wrote:> Dear all, > > > > Could you please give me a hand on parallel function from package > lattice? > > > > On the R command console, the following commands can output a > parallel coordinate plot to the pdf file. > > library(lattice); pdf("trial.pdf"); data(iris); parallel(~iris[1:4] | > Species, iris); dev.off(); > > However, if these commands are encapsulated into a function, the > resultant pdf file is empty. For example, we define a simple function > paraExam below, paraExam() may generate a pdf file which is empty > from a pdf viewer. > > paraExam<-function(file="trial.pdf"){ > > library(lattice); > > pdf(file); > > data(iris); > > parallel(~iris[1:4] | Species, iris); > > dev.off(); > > } > > > > Please give me some tips to output parallel coordinate plots to a pdf > file within a function successfully?
Dirk Eddelbuettel
2005-Feb-20 22:09 UTC
[R] Ask for help on the parallel function output to a pdf file
On 21 February 2005 at 08:35, Warren.Jin at csiro.au wrote: | However, if these commands are encapsulated into a function, the | resultant pdf file is empty. For example, we define a simple function | paraExam below, paraExam() may generate a pdf file which is empty from a | pdf viewer. | | paraExam<-function(file="trial.pdf"){ | library(lattice); | pdf(file); | data(iris); | parallel(~iris[1:4] | Species, iris); | dev.off(); | } It's the (current) mother of all FAQs: You need a print() about your lattice plot command, i.e. print(parallel(~iris[1:4] | Species, iris)) Dirk PS You can drop the ';'. -- Better to have an approximate answer to the right question than a precise answer to the wrong question. -- John Tukey as quoted by John Chambers
Seemingly Similar Threads
- Problems with lattice-histograms or png within loops
- lattice graphics empty in Sweave
- defmacro and bwplot incompatibilities?
- mathematical expression in varnames of lattice parallel plot
- Request: Optimum value of cost complexity parameter "k" in "tree" package