Entering edit mode
lcarvalh@btk.fi
▴
50
@lcarvalhbtkfi-5223
Last seen 10.2 years ago
I have a problem when creating a correlation plot when called within
a
function, if called directly there is no problem. Can anyone find out
why? The
code is below.
Code:
load("norm.matrix.RData")
require(lattice)
#This works and the figure is produced:
png(file="correlation.png", width=600, height=600)
levelplot(cor(data), col.regions = rainbow(100,start=.1,
end=.35),scales =
list(x = list(rot = 45)), ylab="", xlab="", main="" )
dev.off()
#The following does not produce a figure, why?
saveCorrelationPlot <- function(data, fName) {
#quartz()
x11()
png(file=fName, width=600, height=600)
levelplot(cor(data), col.regions = rainbow(100,start=.1,
end=.35),scales =
list(x = list(rot = 45)), ylab="", xlab="", main="" )
dev.off()
}
saveCorrelationPlot(data, "correlation2.png")
Thanks,
Leonor