I am having a problem with a couple R functions I wrote. I have 2 plotting functions and I want to write a function that creates plots for both of the functions. This function looks like this
plotBoth = function(path = NULL){
plotPopulationStats(path)
plotInstructionFrequencies(path)
}
However only whichever instruction I call second gets plotted, while the first instruction only plots a blank window. Below are simplified versions of these functions.
plotInstructionFrequencies = function(path = NULL){
quartz()
table <- read.table(path, header=TRUE);
frame <- as.data.frame(table);
frame$time = seq(1, length(table$noop));
frame$mean = NULL
frame$sd = NULL
frame$variance = NULL
Molten <- melt(frame, id.vars = "time");
ggplot(Molten, aes(x = time, y = value, colour = variable)) + geom_line()
}
and
plotPopulationStats = function(path = NULL){
quartz()
table <- read.table(path, header=TRUE);
frame <- as.data.frame(table);
frame$time = seq(1, length(table$noop));
frame$noop = NULL
frame$plus = NULL
...
frame$store = NULL
Molten <- melt(frame, id.vars = "time");
ggplot(Molten, aes(x = time, y = value, colour = variable)) + geom_line();
}
All the functions are in separate files, but I would like to have them all in one file.
Both functions plot fine when called individually.