Extending my code: RESOLVED

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

Extending my code: RESOLVED

Ogbos
Dear Jeff and Jim,
Thank you for sorting out this for me.
Replacing text(as.Date("2005-03-13"),5900,"b") with:
text(as.POSIXct(("2005-03-13 09:00:00"),5900,"b") resolved the problem.
Warmest regards
Ogbos
On Sun, Feb 17, 2019 at 3:05 AM Jim Lemon <[hidden email]> wrote:

>
> Hi Ogbos,
> Remember that there is an underlying numeric representation of dates.
> as.Date assigns dates a number of days from an agreed origin
> (1970-01-01) while POSIX dates assign a number of seconds. If you plot
> in one system and then try to add points in another, it's not going to
> work.
>
> Jim
>
> On Sun, Feb 17, 2019 at 12:55 PM Ogbos Okike <[hidden email]> wrote:
> >
> > Dear Jim,
> > Thank you and welcome back. It seems you have been away as you have not been responding to people's questions as before.
> >
> > I have just made a correction on my original question. Please have a look and check if I can still go the way u have suggested or if the correction would call for another approach.
> > Best regards
> > Ogbos
> >
> >
> > On Sun, Feb 17, 2019, 02:22 Jim Lemon <[hidden email]> wrote:
> >>
> >> Hi Ogbos,
> >> It may be easier to use strptime:
> >>
> >> dta<-data.frame(year=rep(2005,5),month=rep("05",5),
> >>  day=c("01","06","11","16","21"),
> >>  hour=c(2,4,6,8,10),minute=rep(0,5),second=rep(0,5),value=1:5)
> >> dta$Ptime<-strptime(paste(paste(dta$year,dta$month,dta$day,sep="-"),
> >>  paste(dta$hour,dta$minute,dta$second,sep=":")),"%Y-%m-%d %H:%M:%S")
> >> plot(dta$Ptime,dta$value)
> >> text(strptime("2005-05-04 09:00:00","%Y-%m-%d %H:%M:%S"),4,"b")
> >>
> >> Jim
> >>
> >> > On February 16, 2019 1:08:38 PM PST, Ogbos Okike <[hidden email]> wrote:
> >> > >Dear Jeff,
> >> > >One more problem please.
> >> > >
> >> > >When I used as.Date(ISOdate(dta$year, dta$month, dta$day,dta$hour)) to
> >> > >handle date, I could use text(as.Date("2005-03-13"),-9,"b") to label
> >> > >my plot.
> >> > >
> >> > >Now that I am using as.POSIXct(ISOdatetime(year,
> >> > >month,day,hour,0,0))), can you please tell me how to text "b" on the
> >> > >point corresponding with 1960-05-04 09:00:00 on my plot.
> >> > >
> >> > >Many thanks for your extra time.
> >> > >
> >> > >Best wishes
> >> > >Ogbos

______________________________________________
[hidden email] mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.