[R] Date order question

Ebert,Timothy Aaron tebert @end|ng |rom u||@edu
Wed Jan 4 22:20:03 CET 2023


1) Your "dates" are not being processed as dates. They are strings.
2) As written your date "01-01" comes first because year is not specified and January comes before December.
3) A library statement is missing. I tried running the program and theme_cowplot() was not found.

As you are plotting strings, you could put a space character in front of the December dates so that they are first. 
date<-c(" 12-29"," 12-30","01-01")
That fixes the problem in this example. You can order all the dates by putting more spaces in front of earlier years. That will get messy.


Tim

-----Original Message-----
From: R-help <r-help-bounces using r-project.org> On Behalf Of Thomas Subia
Sent: Wednesday, January 4, 2023 4:08 PM
To: r-help using r-project.org
Subject: [R] Date order question

[External Email]

Colleagues,

date<-c("12-29","12-30","01-01")
PT <- c(.106,.130,.121)
data <- data.frame(date,PT)
ggplot(data, aes(x=date,y=PT,group=1))+
  geom_point(size=4)+
  geom_line()+
  geom_hline(yintercept =c(1,.60,0,.30,.25,.2))+
  scale_y_continuous(label=scales::label_percent(),breaks=c(1,0.6,0,.3,0.25,0.2))+
  annotate("text", x=2.5, y=.1, label="Very Good",size=5,fontface="bold")+
  annotate("text", x=2.5, y=.225, label="Good",size=5,fontface="bold")+
  annotate("text", x=2.5, y=.28, label="Marginal",size=5,fontface="bold") +
  annotate("text", x=2.5, y=.45, label="Inadequate",size=6,fontface="bold")+
  annotate("text", x=2.5, y=.8, label="OOC",size=6,fontface="bold")+
  annotate("text", x=2.5, y=-.05, label="PT Not Done",size=5,fontface="bold")+
  theme_cowplot()

The plot has the wrong date order.
What is desired is 12-29, 12-30 and 01-01.

Some feedback would be appreciated.

All the best,
Thomas Subia

"De quoi devenir chevre? Des donnees"

______________________________________________
R-help using r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://nam10.safelinks.protection.outlook.com/?url=https%3A%2F%2Fstat.ethz.ch%2Fmailman%2Flistinfo%2Fr-help&data=05%7C01%7Ctebert%40ufl.edu%7C9f58ce4e64d04d2b3f0908daee97dcb5%7C0d4da0f84a314d76ace60a62331e1b84%7C0%7C0%7C638084633565926697%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C&sdata=y7Co7Ae8RJG4AWxjwLLNcvopfUt7fGRBguUovhYaxl8%3D&reserved=0
PLEASE do read the posting guide https://nam10.safelinks.protection.outlook.com/?url=http%3A%2F%2Fwww.r-project.org%2Fposting-guide.html&data=05%7C01%7Ctebert%40ufl.edu%7C9f58ce4e64d04d2b3f0908daee97dcb5%7C0d4da0f84a314d76ace60a62331e1b84%7C0%7C0%7C638084633565926697%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C&sdata=pTYhbgrmoAu6g3%2FDepzJJt45Euazik4D6UJKByOZKuQ%3D&reserved=0
and provide commented, minimal, self-contained, reproducible code.



More information about the R-help mailing list