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 6165161
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T22:07:04+00:00 2026-05-23T22:07:04+00:00

I have the following data and am trying to create a barplot in R

  • 0

I have the following data and am trying to create a barplot in R with ggplot2 which have values associated with date values

conv = c(10, 4.76, 17.14, 25, 26.47, 37.5, 20.83, 25.53, 32.5, 16.7, 27.33)
click = c(20, 42, 35, 28, 34, 48, 48, 47, 40, 30, 30)

dat <- data.frame(date=c("July 7", "July 8", "July 9", "July 10", "July 11", "July 12", "July 13",
                         "July 14", "July 15", "July 16", "July 17"), click=c(click), conv=c(conv))
dat

However, when I run the following commands, the bars aren’t in the proper order.

library(ggplot2)
ggplot(dat, aes(date, conv)) +  geom_bar(fill="#336699") + ylim(c(0,50)) +
        opts(title="") +
        opts(axis.text.y=theme_text(family="sans", face="bold", size=10)) +
        opts(axis.text.x=theme_text(family="sans", face="bold", size=8)) +
        opts(plot.title = theme_text(size=15, face="bold")) +
        xlab("") + ylab("")

The variable date is properly ordered from July 7 to July 17, and don’t know why ggplot2 has a problem with this. Is there a quick function to fix this problem without having to reorder the data in the original data set.

  • 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-23T22:07:05+00:00Added an answer on May 23, 2026 at 10:07 pm

    The reason that your sort order does not work is because you have a character string, not dates. Your best option is to convert your dates into date format:

    dat$date <- as.Date(paste(dat$date, "2011"), format="%b %d %Y")
    
    ggplot(dat, aes(as.character(date), conv)) +  geom_bar(fill="#336699") + 
        ylim(c(0,50)) +
        opts(title="") +
        opts(axis.text.y=theme_text(family="sans", face="bold", size=10)) +
        opts(axis.text.x=theme_text(family="sans", face="bold", size=8, angle=90)) +
        opts(plot.title = theme_text(size=15, face="bold")) +
        xlab("") + ylab("")
    

    enter image description here

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

Sidebar

Related Questions

I am trying create a data.frame from which to create a graph. I have
I have the following data set that I am trying to plot with ggplot2,
I have the following data | Item | Value | Date | ------------------------------ |
I have a sql table which have the following data, Id City Country ---
I'm trying to create a simple binaryStreamReader in javascript. Currently I have the following:
I have the following class and I am trying to create an interface for
I have the following code. I'm trying to create the store via json. I
I am trying to create a histogram data using following query: SELECT FLOOR(Max_Irrad/10) AS
I am trying to use use the following JSON data to create the following
I have following data to save in database using php my data is :

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.