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

  • Home
  • SEARCH
  • 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 659389
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T23:02:20+00:00 2026-05-13T23:02:20+00:00

I am working with a data frame where one of the columns consists of

  • 0

I am working with a data frame where one of the columns consists of POSIXct date-time values. I am trying to plot a histogram of these timestamps using ggplot2 but I’m having two issues:

  1. I don’t know how to set the binwidth in geom_histogram(). I’d like to set each bin to a day or a week. I’ve tried providing a difftime object, but I get an error. I also tried binwidth=1 but R just hangs.

  2. How do I set the limits in scale_x_time()? The only way I could get it to work was by converting my POSIXct timestamps using as.Date().

  • 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-05-13T23:02:20+00:00Added an answer on May 13, 2026 at 11:02 pm
    1. The binwidth is measured in seconds, so to bin per week set binwidth=7*24*60*60.
    2. Limits can be given as a vector of 2 POSIXct objects.

    An example:

    y<-as.POSIXct('1970/01/01')+cumsum(rnorm(100,mean=24*60*60,sd=24*60*60))
    p<-qplot(y,binwidth=7*24*60*60,fill=I('steelblue'),col=I('black'))
    p<-p+scale_x_datetime(major="1 week",
                          minor="1 days",
                          format="%e/%m/%Y",
                          limits=c(as.POSIXct('1970/02/01'),
                                   as.POSIXct('1970/03/31')))
    print(p)
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to plot two sets of data wrt to time on the same
im working with core-data for the first time, and my app is handling a
I'm working with a large data frame, and have run up against RAM limits.
I am trying to create nice (!) polar plot with the following data. gr1
I'm working on a data.frame with about 700 000 rows. It's containing the ids
I'm trying to convert three character variables in a data frame to factors, and
I have a large data frame that Im working with, the first few lines
I am working with a data frame in which I need to edit the
I have some irregular data in one column. my.table <-read.table(text=ticker,date,last a,12/20/2011,289295 a,12/21/2011,NA a,12/27/2011,297001 a,12/28/2011,NA
I have a data frame with two columns. The first column defines subsets of

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.