[R] Question on big JPG plots in function warpping format

From: <alexfang_at_stat.rutgers.edu>
Date: Sat 11 Feb 2006 - 02:41:10 EST

Hello:

I have problems generating big JPG plots in functions. the following code runs fine in the script:

#### runs fine in script, generate 40k "test1.jpg" in the given directory plotPlatesAlong <- c(1:5)
plotDirPath <- paste(dataPath, "OutputPlots\\", sep="") filename <- paste(plotDirPath,"test1.jpg", sep="") jpeg(file=filename)
plotHeatTrellis(dataPath, plotVariable = "Raw", plotPlatesAlong)

    # here plotHeatTrellis() generates a complicate plot, but it works dev.off()
#### End of script

but if I wrap it in a function, it doesn't work.

######## put it in a function and run test(dataPath)
######## it will make "test1.jpg" in the given directory, but only 6k in size
######## and if I open the file, it's blank
test <- function(dataPath) {
plotPlatesAlong <- c(1:5)
plotDirPath <- paste(dataPath, "OutputPlots\\", sep="") filename <- paste(plotDirPath,"test1.jpg", sep="") jpeg(file=filename) #
plotHeatTrellis(dataPath, plotVariable = "Raw", plotPlatesAlong) dev.off()
}
######### enf of the program

I've tested the simple plot function, like

########## works fine both with in script and function wrapping format testplot <- function(plotDirPath) {
filename1 <- paste(plotDirPath, "test1.jpg",sep="") jpeg(file=filename1)
plot(1:10, rnorm(10, 0), type="b")
dev.off()
}
###########

Any one have any clues, why this happen and how could I fix my code and my mine working also in the function wrapping format? Thanks.

best, Alex



R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html Received on Sat Feb 11 03:00:27 2006

This archive was generated by hypermail 2.1.8 : Fri 03 Mar 2006 - 03:42:27 EST