Chapter 3: error executing ggsave to create final plot of results
The following command in email_classify.R fails
ggsave(plot = class.plot, filename = file.path("images", "03_final_classification.pdf"), height = 10, width = 10)
Throws this error: Error in seq.default(min, max, by = by) : invalid (to - from)/by in seq(.)
This is using R version 2.15.0 and OSX 10.7.3
Does just calling print(class.plot) produce the same error?
Yes, print(class.plot) returns the same error too.
I notice also that print(class.res) outputs complete different figures than are printed in the book. Although I assuming this is because the data in the data dir is different atm.
Hmmm. This is quite hard to debug since the error message is so vague. I'll try the code again.
What version of ggplot2 are you running?
My installation reports that I'm using ggplot2_0.9.1
I also has this bug..
Error in seq.default(min, max, by = by) : invalid (to - from)/by in seq(.)
I think that's caused by the "scale_x_log10" function, in the result of easyham2.class, there are some zero-value caused by precison
I had the same problem and agree with hanfelsun that its related to the scale_x_log_10 functions. I was able to get around this by plotting the log of the values for pr.Spam & pr.Ham so avoiding the need to use these functions. ie try this code for your plot instead:
class.plot <- ggplot(class.df, aes(x = log(pr.Ham), log(pr.Spam))) + geom_point(aes(shape = Type, alpha = 0.5)) + stat_abline(yintercept = 0, slope = 1) + scale_shape_manual(values = c("EASYHAM" = 1, "HARDHAM" = 2, "SPAM" = 3), name = "Email Type") + scale_alpha(guide="none") + xlab("log[Pr(HAM)]") + ylab("log[Pr(SPAM)]") + theme_bw() + theme(axis.text.x = element_blank(), axis.text.y = element_blank())