Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Chapter 3: error executing ggsave to create final plot of results #6

Open
DanBuchan opened this issue May 20, 2012 · 8 comments
Open

Comments

@DanBuchan
Copy link

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

@johnmyleswhite
Copy link
Owner

Does just calling print(class.plot) produce the same error?

@DanBuchan
Copy link
Author

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.

@johnmyleswhite
Copy link
Owner

Hmmm. This is quite hard to debug since the error message is so vague. I'll try the code again.

@drewconway
Copy link
Collaborator

What version of ggplot2 are you running?

@DanBuchan
Copy link
Author

My installation reports that I'm using ggplot2_0.9.1

@hanfeisun
Copy link

I also has this bug..

Error in seq.default(min, max, by = by) :
invalid (to - from)/by in seq(.)

@hanfeisun
Copy link

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

@pcp135
Copy link
Contributor

pcp135 commented Sep 16, 2012

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())

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants