Re: [R] Extending my code

2019-02-16 Thread Jim Lemon
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 S

Re: [R] Extending my code

2019-02-16 Thread Jeff Newmiller
Jim has pointed out the strptime function, but you can use as.POSIXct function also... so as.POSIXct( "2005-03-13 09:00:00" ) as.POSIXct( "03/13/2005 9:00", format="%m/%d/%Y %H:%M" ) or other variations should work. On February 16, 2019 5:41:29 PM PST, Ogbos Okike wrote: >Dear Jeff, >My erro

Re: [R] Extending my code

2019-02-16 Thread Ogbos Okike
Dear Jeff, My error please and sorry about that. Not "1960-05-04 09:00:00". I meant to write as.Date("2005-03-13"),-9,"b") and "2005-03-13 09:00:00". My problem is the additional time factor. I can text anywhere on my plot when dealing with /mm/dd but I can't handle the new /mm/dd/hh/mm/

Re: [R] Extending my code

2019-02-16 Thread Jim Lemon
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$secon

Re: [R] Extending my code

2019-02-16 Thread Jeff Newmiller
I have no idea how text(as.Date("2005-03-13"),-9,"b") would mark your plot anywhere near 1960-05-04 09:00:00. Perhaps someone else does. Or perhaps you can provide an actual minimal working example of what you had working before you changed to POSIXct. On February 16, 2019 1:08:38 PM PST, Ogbos

Re: [R] Extending my code

2019-02-16 Thread Ogbos Okike
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" o

Re: [R] Extending my code

2019-02-14 Thread Ogbos Okike
Dear Jeff, Please hold. It is begging to work. There was an error somewhere. One ")" is missing and as I went back to check the lines one by one with cursor, I stubbed on non matching bracket. I completed, run the code again and got some result. Will get back to you once I am through. Thanks in

Re: [R] Extending my code

2019-02-14 Thread Ogbos Okike
Dear Jeff, Thank you so much. I ran the code but got an error message. I then try to run them line by line. The problem is in: dta$datetime <- with( dta, as.POSIXct(ISOdatetime(year, month,day,hour,0,0))) Error in with(dta, as.POSIXct(ISOdatetime(year, month, day, hour, 0, 0))) : object 'dta'

Re: [R] Extending my code

2019-02-14 Thread Jeff Newmiller
The Date class is not designed to handle time... you need to use the ISOdatetime function and convert to POSIXct instead of Date. Just be sure to set your timezone to some appropriate value before you convert any times into datetime types. Sys.setenv( TZ="GMT" ) # avoid using `data` as that is