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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T07:29:58+00:00 2026-06-07T07:29:58+00:00

Dear fellow homo sapiens, I’ve created this graph using the code below (except without

  • 0

Dear fellow homo sapiens,

I’ve created this graph using the code below (except without + scale_x_date).

The data-set that I’ve used to do this is found HERE. It looks like this:

GFC1CARi<-read.csv("demo.csv")
head(GFC1CARi)
  X         XX   variable       value    Var
1 1 2008-07-17 Financials 0.001772705 Financ
2 2 2008-07-18 Financials 0.017306086 Financ
3 3 2008-07-21 Financials 0.010745136 Financ
4 4 2008-07-22 Financials 0.021152194 Financ
5 5 2008-07-23 Financials 0.031195805 Financ
6 6 2008-07-24 Financials 0.026534444 Financ

As you’ll see the in picture, the x-axis displays dates such as “Aug”, “Sep” …. . However, I want it to be something similar to “08/2007”, “09/2007” … . So, my attempt at doing this is displayed below, but it doesn’t work.

p <- ggplot(data=GFC1CARi,aes(x=XX, y=value, colour=Var)) +
        geom_line() + 
        opts(legend.position = "none") + 
        xlab(" ") + 
        ylab("Cumulative abnormal return") + 
        scale_x_date(labels = date_format("%m/%Y"),breaks = "1 month")

p <- direct.label(p+xlim(min(GFC1CARi$XX), max(GFC1CARi$XX)+20))

I’ve tried many other variation of breaks = ?? and date_format and I can’t get the %m/%Y to show, it’ll always be “Aug” .. “Sep” .. “Oct”. As requested by Joran:

> str(GFC1CARi)
'data.frame':   1730 obs. of  5 variables:
 $ X       : int  1 2 3 4 5 6 7 8 9 10 ...
 $ XX      : POSIXct, format: "2008-07-17" "2008-07-18" "2008-07-21" "2008-07-22" ...
 $ variable: Factor w/ 10 levels "Financials","Industrials",..: 1 1 1 1 1 1 1 1 1 1 ...
 $ value   : num  0.00177 0.01731 0.01075 0.02115 0.0312 ...
 $ Var     : chr  "Financ" "Financ" "Financ" "Financ" ...

I’ve even tried to change the date formate from POSIXct to as.Date as follows:

GFC1CARi[,2]<-as.Date(GFC1CARi[,2])
str(GFC1CARi)
'data.frame':   1730 obs. of  5 variables:
 $ X       : int  1 2 3 4 5 6 7 8 9 10 ...
 $ XX      : Date, format: "2008-07-16" "2008-07-17" ...
 $ variable: Factor w/ 10 levels "Financials","Industrials",..: 1 1 1 1 1 1 1 1 1 1 ...
 $ value   : num  0.000983 0.015822 0.008339 0.017987 0.027186 ...
 $ Var     : chr  "Financ" "Financ" "Financ" "Financ" ...

This doesn’t fix the situation. Instead the X-axis is now { “Oct”, “Jan”, “Apr” }, and that’s it.

Thanks everyone.

  • 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-07T07:30:00+00:00Added an answer on June 7, 2026 at 7:30 am

    My apologies, I was being very dense. I thought the error you were getting was happening before the attempt to use directlabels, not after.

    The call to xlim is simply stomping on the x axis formatting. Just put the scale_x_date call inside the direct.labels command works for me:

    p <- direct.label(p + 
                      xlim(min(dat$XX), max(dat$XX)+20) + 
                      scale_x_date(labels = date_format("%m/%Y"),breaks = "1 month"))
    

    enter image description here

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

Sidebar

Related Questions

dear all..i've a textfield, it using barcode scanner for input data..after scan it shows
dear all..i have this code: <script> var str=KD-R435MUN2D; var matches=str.match(/(EE|[EJU]).*(D)/i); if (matches) { var
Dear Folk's i'm using the following code in order to send the bytes of
Dear friends,I want to extract text 平均3.6 星 from this code segment excerpted from
Dear all, this is going to be tough: I have created a game object
dear all i want to know how to submit asp.net form data using jquery
dear all.can you tell me how to collecting this data in mysql: item colour
Dear all from the below mentioned table im picking imgurl with this query but
Dear fellow readers on Stack Overflow, I am currently working in CSS and I
Dear all,Now i have this question in my java program,I think it should be

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.