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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T21:15:43+00:00 2026-05-22T21:15:43+00:00

I want to plot the data as a time series (quarterly) but the plot

  • 0

I want to plot the data as a time series (quarterly) but the plot keeps treating the dates as Data not labels or time?

Trying to keep my initial exercise very simple, (have more complex stuff to get on with, it would be a snap with Excel or even GDocs!)
I am reading a very small table from csv (using read.csv) as

This is the display for Corl (my data in r)

    Date Survey Actual
1 2011-06-30     60     NA
2 2011-03-31     55     50
3 2010-12-31     48     44
4 2010-09-30     48     36
5 2010-06-30     56     75
6 2010-03-31     57     41

I tried to convert to date using Corl$Date <- as.Date(Corl$Date) but no difference.

I have used both plot(Corl) and plot.ts(Corl)

I’ll then want to run correlate and auto correlate but I seem to be missing a basic concept for the data structure?

I also tried inverting the columns and rows,

      V1         V2         V3         V4         V5         V6
1   Date 2010-03-31 2010-06-30 2010-09-30 2010-12-31 2011-03-31
2 Survey         57         56         48         48         55
3 Actual         41         75         36         44         50
      V7
1 2011-06-30
2         60
3           

dput(Corl)
structure(list(Date = structure(c(15155, 15064, 14974, 14882, 
14790, 14699), class = "Date"), Survey = c(60L, 55L, 48L, 48L, 
56L, 57L), Actual = c(NA, 50L, 44L, 36L, 75L, 41L)), .Names = c("Date", 
"Survey", "Actual"), row.names = c(NA, -6L), class = "data.frame")

Plot as follows:
BadChart 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-05-22T21:15:44+00:00Added an answer on May 22, 2026 at 9:15 pm

    From the output of dput(Corl) we don’t have to guess at how the Date values are stored in Corl. As you can see below, the Dates are stored as class = “Date”. That makes this fairly easy.

    library(zoo)
    
    Corl <- structure(list(Date = structure(c(15155, 15064, 14974, 14882,
      14790, 14699), class = "Date"), Survey = c(60L, 55L, 48L, 48L,
        56L, 57L), Actual = c(NA, 50L, 44L, 36L, 75L, 41L)), .Names = c("Date",
          "Survey", "Actual"), row.names = c(NA, -6L), class = "data.frame")
    
    Corl.zoo <- read.zoo(Corl, FUN=as.yearqtr)
    Corl.zoo
    
            Survey Actual
    2010 Q1     57     41
    2010 Q2     56     75
    2010 Q3     48     36
    2010 Q4     48     44
    2011 Q1     55     50
    2011 Q2     60     NA
    
    plot(Corl.zoo)
    

    enter image description here

    Edit 1 ======================================================

    Before you ask, here’s a way to add vertical grid lines and more labels across the x axis. All I did was modify the example code at the bottom of the following link:

    http://rss.acs.unt.edu/Rdoc/library/zoo/html/plot.zoo.html

    my.panel <- function(...) {
       lines(...)
       #This line adds the vertical grid lines
       abline(v=time(Corl.zoo), col="lightgray", lty=3)
       panel.number <- parent.frame()$panel.number
       # if bottom panel
       if (!length(panel.number) || panel.number == NCOL(Corl.zoo)) {
          # next line only if non-labelled ticks wanted for each point
          axis(1, at = time(Corl.zoo), lab = FALSE)
          labcou <- 1 #Put a label, counting between labels
          ix <- seq(1, length(Corl.zoo), labcou)
          labs <- format(time(Corl.zoo), "%Y\nQ%q\n ")
          axis(1, at = time(Corl.zoo)[ix], lab = labs[ix], tcl = -0.5, padj=0.6, cex.axis = 1)
       }
    }
    
    plot(Corl.zoo, panel = my.panel, xaxt = "n", main="My Title", xlab="")
    

    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 using ggplot2 to plot simple line charts of time series data. One
I'm new to matlab and I want to plot some data in real time.
I want to use core-plot for drawing line graph dynamically. data won't come at
I want to create a pairs plot in R that has labels on the
I want to place two Time Series Charts sharing the same time domain axis
I have a data.frame with 3 time series in it, shown below. When I
I have a bunch of measurements over time and I want to plot them
I have a data frame containing multiple time series of returns, stored in columns.
I have a time series(a csv file) data that looks like below. Each observation
Ok, I can create a plot. But if I want the plot to 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.