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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T01:48:26+00:00 2026-05-25T01:48:26+00:00

I’m trying to plot some grades I’m pulling from an external source. The date

  • 0

I’m trying to plot some grades I’m pulling from an external source. The date format comes in looking like this:

2011-08-23T17:07:05

So I parse it with strptime(date, "%FT%X") and get a POSIXlt. I end up with a complete data frame that looks like this:

                  date    subject  grade
1  2011-08-23 17:07:05 AP Biology  95.83
2  2011-08-24 17:07:03 AP Biology  95.83
3  2011-08-25 17:08:27 AP Biology  95.83
4  2011-08-17 17:05:54 US History 157.14
5  2011-08-18 17:05:24 US History 157.14
6  2011-08-19 17:05:35 US History 157.14
7  2011-08-22 17:06:25 US History 157.14
8  2011-08-23 17:07:05 US History 157.14
9  2011-08-24 17:07:03 US History 157.14
10 2011-08-25 17:08:27 US History 157.14
11 2011-08-19 17:05:35   Yearbook   0.00
12 2011-08-22 17:06:25   Yearbook   0.00
13 2011-08-23 17:07:05   Yearbook 100.00
14 2011-08-24 17:07:03   Yearbook 100.00
15 2011-08-25 17:08:27   Yearbook 100.00

With the following structure:

'data.frame':   15 obs. of  3 variables:
 $ date   : POSIXlt, format: "2011-08-23 17:07:05" "2011-08-24 17:07:03" ...
 $ subject: Factor w/ 3 levels "AP Biology","US History",..: 1 1 1 2 2 2 2 ...
 $ grade  : num  95.8 95.8 95.8 157.1 157.1 ...

When I try to plot this data:

> ggplot(data=grades, aes(date, grade, factor=subject)) + geom_line()
Error in if (length(range) == 1 || diff(range) == 0) { : 
  missing value where TRUE/FALSE needed

I don’t know what I’m doing wrong here. I narrowed it down to the date handling by doing this:

ggplot(data=grades,
       aes(seq(length(grades[,1])),
           grade, color=subject)) + geom_line()

… but how do I do the date handling correctly?

  • 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-25T01:48:27+00:00Added an answer on May 25, 2026 at 1:48 am

    Only times of class POSIXct are supported in ggplot2. Class POSIXct represents the (signed) number of seconds since the beginning of 1970 (in the UTC timezone) as a numeric vector. Class POSIXlt is a named list of vectors representing nine elements (sec, min, hour, etc.).

    You can use the following:

    grades$date <- as.POSIXct(grades$date)
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

For some reason, after submitting a string like this Jack’s Spindle from a text
I have some data like this: 1 2 3 4 5 9 2 6
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I'm trying to decode HTML entries from here NYTimes.com and I cannot figure out
Does anyone know how can I replace this 2 symbol below from the string
I am trying to understand how to use SyndicationItem to display feed which is
Basically, what I'm trying to create is a page of div tags, each has
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have just tried to save a simple *.rtf file with some websites and
I have a jquery bug and I've been looking for hours now, I can't

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.