Re: [R] convert 12 time stamp to 24 hour
Hi > -Original Message- > From: e-letter [mailto:inp...@gmail.com] > Sent: Monday, February 11, 2013 3:11 PM > To: PIKAL Petr > Cc: r-help@r-project.org > Subject: Re: [R] convert 12 time stamp to 24 hour > > On 11/02/2013, PIKAL Petr wrote: > > > > str(testtimedataset) > > With my real data set, revealed that after conversion, the time series > data consists of 'chr' which I guess means character type data, Do not guess. There is extensive help in R which you can ivoke by"?". ?mode ?typeof > reporting the following error: > > Error in plot.window(...) : need finite 'xlim' values In addition: > Warning messages: > 1: In xy.coords(x, y, xlabel, ylabel, log) : NAs introduced by coercion > 2: In min(x) : no non-missing arguments to min; returning Inf > 3: In max(x) : no non-missing arguments to max; returning -Inf > > > Does this mean I must convert the 24-hour time series values to POSIX*t Yes. > type objects; if so how please? ?strptime Regards Petr > > > > Anyway, by > > > > plot(testdata~testtimedataset$V1) > > > > you will get rid of error message but depending on testtimedataset > > mode you can get different one. > > > > Confirmed, thanks. __ R-help@r-project.org mailing list 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.
Re: [R] convert 12 time stamp to 24 hour
On 11/02/2013, PIKAL Petr wrote: > > str(testtimedataset) With my real data set, revealed that after conversion, the time series data consists of 'chr' which I guess means character type data, reporting the following error: Error in plot.window(...) : need finite 'xlim' values In addition: Warning messages: 1: In xy.coords(x, y, xlabel, ylabel, log) : NAs introduced by coercion 2: In min(x) : no non-missing arguments to min; returning Inf 3: In max(x) : no non-missing arguments to max; returning -Inf Does this mean I must convert the 24-hour time series values to POSIX*t type objects; if so how please? > > Anyway, by > > plot(testdata~testtimedataset$V1) > > you will get rid of error message but depending on testtimedataset mode you > can get different one. > Confirmed, thanks. __ R-help@r-project.org mailing list 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.
Re: [R] convert 12 time stamp to 24 hour
Hi > -Original Message- > From: r-help-boun...@r-project.org [mailto:r-help-bounces@r- > project.org] On Behalf Of e-letter > Sent: Monday, February 11, 2013 2:31 PM > To: r-help@r-project.org > Subject: Re: [R] convert 12 time stamp to 24 hour > > Readers, > > Have since tried to plot converted 24 hour data: > > testtimedataset > V1 > 1 13:01:41 > 2 13:02:10 > 3 13:02:38 > 4 13:03:05 > 5 13:03259 > > > testdata<-seq(1:5) > > plot(testdata~testtimedataset) > Error in function (formula, data = NULL, subset = NULL, na.action = > na.fail, : > invalid type (list) for variable 'testtimedataset' > > Was expecting to see a graph with ordinate values 1:5 for the time > series values on the abscissa. What is the mistake please? The main mistake is that you did not pay attention to provided documentation especially R-intro. You try to plot a data frame against a vector testdata. We do not know, what is testtimedataset. You shall provide at least str(testtimedataset) or better dput(testtimedataset) Anyway, by plot(testdata~testtimedataset$V1) you will get rid of error message but depending on testtimedataset mode you can get different one. Regards Petr > > -- > r2151 > > __ > R-help@r-project.org mailing list > 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. __ R-help@r-project.org mailing list 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.
Re: [R] convert 12 time stamp to 24 hour
Hello, You're trying to plot the df, not the column. Try plot(testdata ~ testtimedataset$V1) Hope this helps, Rui Barradas Em 11-02-2013 13:30, e-letter escreveu: Readers, Have since tried to plot converted 24 hour data: testtimedataset V1 1 13:01:41 2 13:02:10 3 13:02:38 4 13:03:05 5 13:03259 testdata<-seq(1:5) plot(testdata~testtimedataset) Error in function (formula, data = NULL, subset = NULL, na.action = na.fail, : invalid type (list) for variable 'testtimedataset' Was expecting to see a graph with ordinate values 1:5 for the time series values on the abscissa. What is the mistake please? -- r2151 __ R-help@r-project.org mailing list 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. __ R-help@r-project.org mailing list 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.
Re: [R] convert 12 time stamp to 24 hour
Readers, Have since tried to plot converted 24 hour data: testtimedataset V1 1 13:01:41 2 13:02:10 3 13:02:38 4 13:03:05 5 13:03259 > testdata<-seq(1:5) > plot(testdata~testtimedataset) Error in function (formula, data = NULL, subset = NULL, na.action = na.fail, : invalid type (list) for variable 'testtimedataset' Was expecting to see a graph with ordinate values 1:5 for the time series values on the abscissa. What is the mistake please? -- r2151 __ R-help@r-project.org mailing list 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.
Re: [R] convert 12 time stamp to 24 hour
On 08/02/2013, e-letter wrote: > Readers, > > For a 12 hour time stamp: > >> testtime<-("2013-01-01 01:00:01 PM") >> testtime > [1] "2013-01-01 01:00:01 PM" >> testtime24hour<-strftime(testtime,'%H:%M:%S') >> testtime24hour > [1] "01:00:01" > Have realised that the object is of type 'character'. When this conversion is applied to a vector and then the 'plot' function applied (i.e. plot another vector against the vector of 24-hour time series values), receive an error. How to convert the values "01:00:01" to 'ts' objects? __ R-help@r-project.org mailing list 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.
Re: [R] convert 12 time stamp to 24 hour
Hi, library(lubridate) ymd_hms(testtime) 1 parsed with %Y-%m-%d %I:%M:%S %p #[1] "2013-01-01 13:00:01 UTC" A.K. - Original Message - From: e-letter To: r-help@r-project.org Cc: Sent: Friday, February 8, 2013 4:44 AM Subject: [R] convert 12 time stamp to 24 hour Readers, For a 12 hour time stamp: > testtime<-("2013-01-01 01:00:01 PM") > testtime [1] "2013-01-01 01:00:01 PM" > testtime24hour<-strftime(testtime,'%H:%M:%S') > testtime24hour [1] "01:00:01" how to convert to 24 hour format so that the object 'testtime24hour' is: '13:00:01' Thanks. -- r2151 __ R-help@r-project.org mailing list 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. __ R-help@r-project.org mailing list 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.
Re: [R] convert 12 time stamp to 24 hour
Hi Does not work in some locale environment > strptime(testtime, "%Y-%m-%d %I:%M:%S %p") [1] NA > Sys.getlocale("LC_TIME") [1] "Czech_Czech Republic.1250" > Sys.setlocale("LC_TIME", "C") [1] "C" > strptime(testtime, "%Y-%m-%d %I:%M:%S %p") [1] "2013-01-01 13:00:01" Regards Petr > -Original Message- > From: r-help-boun...@r-project.org [mailto:r-help-bounces@r- > project.org] On Behalf Of Pascal Oettli > Sent: Friday, February 08, 2013 11:08 AM > To: e-letter > Cc: r-help@r-project.org > Subject: Re: [R] convert 12 time stamp to 24 hour > > Hello, > > Try this: > > > testtime<-("2013-01-01 01:00:01 PM") > > strptime(testtime, "%Y-%m-%d %I:%M:%S %p") [1] "2013-01-01 13:00:01" > > HTH, > Pascal > > > Le 08/02/2013 18:44, e-letter a écrit : > > Readers, > > > > For a 12 hour time stamp: > > > >> testtime<-("2013-01-01 01:00:01 PM") > >> testtime > > [1] "2013-01-01 01:00:01 PM" > >> testtime24hour<-strftime(testtime,'%H:%M:%S') > >> testtime24hour > > [1] "01:00:01" > > > > how to convert to 24 hour format so that the object 'testtime24hour' > is: > > > > '13:00:01' > > > > Thanks. > > > > -- > > r2151 > > > > __ > > R-help@r-project.org mailing list > > 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. > > > > __ > R-help@r-project.org mailing list > 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. __ R-help@r-project.org mailing list 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.
Re: [R] convert 12 time stamp to 24 hour
Hello, Try this: > testtime<-("2013-01-01 01:00:01 PM") > strptime(testtime, "%Y-%m-%d %I:%M:%S %p") [1] "2013-01-01 13:00:01" HTH, Pascal Le 08/02/2013 18:44, e-letter a écrit : Readers, For a 12 hour time stamp: testtime<-("2013-01-01 01:00:01 PM") testtime [1] "2013-01-01 01:00:01 PM" testtime24hour<-strftime(testtime,'%H:%M:%S') testtime24hour [1] "01:00:01" how to convert to 24 hour format so that the object 'testtime24hour' is: '13:00:01' Thanks. -- r2151 __ R-help@r-project.org mailing list 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. __ R-help@r-project.org mailing list 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.
[R] convert 12 time stamp to 24 hour
Readers, For a 12 hour time stamp: > testtime<-("2013-01-01 01:00:01 PM") > testtime [1] "2013-01-01 01:00:01 PM" > testtime24hour<-strftime(testtime,'%H:%M:%S') > testtime24hour [1] "01:00:01" how to convert to 24 hour format so that the object 'testtime24hour' is: '13:00:01' Thanks. -- r2151 __ R-help@r-project.org mailing list 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.