Ralf, inside a function you'll need to print the plot using qplot. Change it to P <- qplot(1:10, letters[1:10]) print(P)
This is good practice even at the console, as you can then modify your plots in increments P2 <- P + more commands (text, more points, altered annotations etc) print(P2) etc Bryan ************* Bryan Hanson Acting Chair Professor of Chemistry & Biochemistry DePauw University, Greencastle IN USA On 5/13/10 1:42 AM, "Ralf B" <ralf.bie...@gmail.com> wrote: > I have a script running in the StatET Eclipse environment that > executes the ggplot2 command qplot in a function: > > # Creates the plot > createPlot <- function(){ > print("Lets plot!") > qplot(1:10, letters[1:10]) > } > > When executing the qplot line directly, it works. When executing the > script it does not open a window and it it does not plot. Is there > something important I have forgotten? I know that the function is > called because I always get my 'Lets plot'.... When using normal > graphics plot functions, its also works seamless. > > Of course I am importing the library ggplot2 at the beginning of my > script - here is the import log: > > library(gdata) # for trim function > gdata: Unable to locate valid perl interpreter > gdata: > gdata: read.xls() will be unable to read Excel XLS and XLSX files > gdata: unless the 'perl=' argument is used to specify the location of a > gdata: valid perl intrpreter. > gdata: > gdata: (To avoid display of this message in the future, please ensure > gdata: perl is installed and available on the executable search path.) > gdata: Unable to load perl libaries needed by read.xls() > gdata: to support 'XLX' (Excel 97-2004) files. > > gdata: Unable to load perl libaries needed by read.xls() > gdata: to support 'XLSX' (Excel 2007+) files. > > gdata: Run the function 'installXLSXsupport()' > gdata: to automatically download and install the perl > gdata: libaries needed to support Excel XLS and XLSX formats. > > Attaching package: 'gdata' > > > The following object(s) are masked from package:utils : > > object.size > > Warning message: > package 'gdata' was built under R version 2.10.1 >> library(TTR) # for moving averages (SMA,...) smoothing > Loading required package: xts > Loading required package: zoo > Warning messages: > 1: package 'TTR' was built under R version 2.10.1 > 2: package 'xts' was built under R version 2.10.1 > 3: package 'zoo' was built under R version 2.10.1 >> library(ggplot2) # for plotting results > Loading required package: proto > Loading required package: grid > Loading required package: reshape > Loading required package: plyr > Loading required package: digest > > Attaching package: 'ggplot2' > > > The following object(s) are masked from package:gdata : > > interleave > > Warning messages: > 1: package 'ggplot2' was built under R version 2.10.1 > 2: package 'proto' was built under R version 2.10.1 > 3: package 'reshape' was built under R version 2.10.1 > 4: package 'plyr' was built under R version 2.10.1 > 5: package 'digest' was built under R version 2.10.1 > > > What is wrong here? > > Ralf > > ______________________________________________ > 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-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.