Re: [R] Incorrect Conversion of Datetime

2020-01-08 Thread Jim Lemon
Enrico seems to have found the problem - you can't change dates much by changing the time zone, but transposing month and day will do the trick nicely. The mm/dd/ format and others like it are so common that you always have to be on the lookout for it. Is the sample data you included in your fi

Re: [R] Incorrect Conversion of Datetime

2020-01-08 Thread Enrico Schumann
> On Wed, 8 Jan 2020 17:43:29 +0100, Ogbos Okike > writes: Ogbos> Dear Enrico, Ogbos> Thanks for your time. Ogbos> I have tried to learn how to use dput in R. I have not yet made much progress. Ogbos> I have succeeded in using dput to store my data frame. I first Ogbos> conve

Re: [R] Incorrect Conversion of Datetime

2020-01-08 Thread Jeff Newmiller
a) R cannot deal with POSIXt vectors having more than one timezone in one vector. Won't happen. You need to separate the data into different data frames if you need to deal with importing data with different timezones. b) You say you included the lines Sys.timezone() str(OlsonNames()) in your

Re: [R] Incorrect Conversion of Datetime

2020-01-08 Thread Ogbos Okike
Dear Jeff, Thank you very much for looking into this. I have made some search on ?OlsonNames. System time zones indicates Africa/Lagos whereas the data I am trying to convert are Cosmic ray data prepared at different time zones including Oulu station (Russia), Climax station (America), many parts

Re: [R] Incorrect Conversion of Datetime

2020-01-08 Thread Ogbos Okike
Dear Enrico, Thanks for your time. I have tried to learn how to use dput in R. I have not yet made much progress. I have succeeded in using dput to store my data frame. I first converted my data into a data frame and then used: dput(dd,file="Ogbos2",control = c("keepNA", "keepInteger", "showAttrib

Re: [R] Incorrect Conversion of Datetime

2020-01-08 Thread Jeff Newmiller
In your first email you said you were using Sys.setenv( TZ="GMT" ) in your code, which defines the default assumption for time conversion timezone (at least until you change it). Keep in mind that you may be dealing with data from other timezones than your local one that the operating system us

Re: [R] Incorrect Conversion of Datetime

2020-01-08 Thread Ogbos Okike
Dear Jim, In order to check whether I have a correct time on my system, I run: $ timedatectl and it gives: Local time: Wed 2020-01-08 13:03:44 WAT Universal time: Wed 2020-01-08 12:03:44 UTC RTC time: Wed 2020-01-08 12:03:44 Time zo

Re: [R] Incorrect Conversion of Datetime

2020-01-08 Thread Enrico Schumann
Quoting Ogbos Okike : Dear Friends, A sample of my data is: 98 05 01 028541 98 05 01 038548 98 05 01 048512 98 05 01 058541 98 05 01 068509 98 05 01 078472 98 05 01 088454 98 05 01 098461 98 05 01 108462 98 05 01 118475 98 05 01 128433 98 05 01 13

Re: [R] Incorrect Conversion of Datetime

2020-01-08 Thread Ogbos Okike
Dear Jim, Thank you for coming my assist me. I have tried all you suggested but the same result keep coming. I tried, for example: dta <- read.table("Ohr1may98", col.names = c("year", "month", "day", "hour", "counts")) dta$year <- with( dta, ifelse(year < 50, year + 2000, year + 1900)) dta$date<-s

Re: [R] Incorrect Conversion of Datetime

2020-01-08 Thread Jim Lemon
Hi again, Small typo, should be dta$date<-strptime(paste(dta$year,dta$month,dta$day,dta$hour), "%Y %m %d %H" as I tried it both with and without the century just to check and copied the wrong line. On Wed, Jan 8, 2020 at 9:03 PM Jim Lemon wrote: > > Hi Ogbos, > I get the correct result using s

Re: [R] Incorrect Conversion of Datetime

2020-01-08 Thread Jim Lemon
Hi Ogbos, I get the correct result using strptime: dta$date<-strptime(paste(dta$year,dta$month,dta$day,dta$hour), "%y %m %d %H" ) > dta$date [1] "1998-05-01 02:00:00 AEST" "1998-05-01 03:00:00 AEST" [3] "1998-05-01 04:00:00 AEST" "1998-05-01 05:00:00 AEST" [5] "1998-05-01 06:00:00 AEST" "1998-05-