Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7759233
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T13:34:32+00:00 2026-06-01T13:34:32+00:00

I am following a tutorial in the book Machine Learning for Hackers by Drew

  • 0

I am following a tutorial in the book Machine Learning for Hackers by Drew Conway and John White, and I am stuck with a problem plotting a histogram.
The example code runs up the plotting section here:

> quick.hist <- ggplot(ufo.us, aes(x = DateOccurred)) +
+   geom_histogram() + 
+   scale_x_date(major = "50 years")

produces

Error in continuous_scale(aesthetics, "date", identity, breaks = breaks,  : unused argument(s) (major = "50 years")

and

> ggsave(plot = quick.hist,
+        filename = "C:\test.png",
+        height = 6,
+        width = 8)

produces

Error in inherits(plot, "ggplot") : object 'quick.hist' not found

I am using R version 2.14.2. and the ggplot2 library. Thanks in advance for any help.


Solved

A quick solution that worked for me was to eliminate the ‘+ scale_x_date(major = "50 years")’ part of every line that referenced a label. The final code that produced the histogram was like this:

> quick.hist <- ggplot(ufo.us, aes(x = DateOccurred)) +
+   geom_histogram()

I would like to add labels to the charts at some point, but for now, this solution works with the new version of ggplot2.


Better resolution yet:
I encountered similar problems while running through the book’s hands-on example. I’m posting here the complete snippet for the production of the final plot on in the book (this is not the same plot referenced originally in this question, but it too exposed the same problems).
This fix addresses the issues of

  • old syntax on scale_x_date (thanks Jonas Heidelberg)
  • the need to explicitly reference the scales library (thanks B0WSER)
  • deprecated syntax for legend= (replaced by guide=)
  • deprecated syntax for opts() (replaced by labs() and others)

Changes to the book’s snippet are shown in bold below:

library(ggplot2)
  library(scales)
state.plot <-
    ggplot(all.sightings, aes(x=YearMonth, y=Sightings)) +
    geom_line(aes(color="darkblue")) +
    facet_wrap(~State, nrow=10, ncol=5) +
    theme_bw() +
    scale_color_manual(values=c("darkblue"="darkblue"), guide="none") +
    scale_x_date(breaks= date_breaks(width = "5 years"),
            labels = date_format("%Y")) +
    xlab("Time") + ylab("Nb of Sightings") +
    labs(title="Nb of UFO sightings by Month-Year and US State (1990-2000)")

print(state.plot)

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-01T13:34:33+00:00Added an answer on June 1, 2026 at 1:34 pm

    Have the same problem.

    Adding

    library(scales)
    

    solved this problem.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm new to cakephp and following this tutorial. http://book.cakephp.org/2.0/en/tutorials-and-examples/blog-auth-example/auth.html I have created the blog
I'm following a node.js tutorial from a book called Node Web Developments. Problem: In
I'm currently following a tutorial in a book, and it instructs to create a
I am working through the book Learning WCF and on the first tutorial lab
I'm currently following the Shovell tutorial in the Simply Rails 2 book. On page
We started following the CakePHP Blog tutorial hosted on the website cakephp.org - http://book.cakephp.org/2.0/en/tutorials-and-examples/blog/part-two.html
I am following this tutorial book that involves signing up and user creation for
Sorry if repost I’m new to JSP. I’m following a tutorial from a book,
I'm following a very basic book tutorial on Mac development. We're just creating a
I'm following through the tutorial from the book Agile Web Development with Rails and

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.