Re: [R] Convert character date time to R date-time variable.

2023-12-08 Thread Duncan Murdoch
On 08/12/2023 4:30 p.m., David Winsemius wrote: On 12/7/23 08:21, Sorkin, John wrote: Colleagues, I have a matrix of character data that represents date and time. The format of each element of the matrix is "2020-09-17_00:00:00" How can I convert the elements into a valid R

Re: [R] Convert character date time to R date-time variable.

2023-12-08 Thread David Winsemius
On 12/7/23 08:21, Sorkin, John wrote: Colleagues, I have a matrix of character data that represents date and time. The format of each element of the matrix is "2020-09-17_00:00:00" How can I convert the elements into a valid R date-time constant? You will not be able to s

Re: [R] Convert character date time to R date-time variable.

2023-12-08 Thread Martin Maechler
17_00:00:00", format = "%Y-%m-%d_%H:%M:%S") [1] "2020-09-17 CEST" > (in my time zone). > -Original Message- From: R-help > On Behalf Of Sorkin, John > Sent: Thursday, December 7, 2023 11:22 AM To: > r-help@r-project.org (r-help@r-

Re: [R] Convert character date time to R date-time variable.

2023-12-07 Thread Dirk Eddelbuettel
`anytime` was written for this: > anytime::anytime("2020-09-17_00:00:00") [1] "2020-09-17 CDT" > class(anytime::anytime("2020-09-17_00:00:00")) [1] "POSIXct" "POSIXt" > Dirk -- dirk.eddelbuettel.com | @eddelbuettel | e...@debian.org __

Re: [R] Convert character date time to R date-time variable.

2023-12-07 Thread Rui Barradas
Às 16:30 de 07/12/2023, Rui Barradas escreveu: Às 16:21 de 07/12/2023, Sorkin, John escreveu: Colleagues, I have a matrix of character data that represents date and time. The format of each element of the matrix is "2020-09-17_00:00:00" How can I convert the elements into a valid R

Re: [R] Convert character date time to R date-time variable.

2023-12-07 Thread Rui Barradas
Às 16:21 de 07/12/2023, Sorkin, John escreveu: Colleagues, I have a matrix of character data that represents date and time. The format of each element of the matrix is "2020-09-17_00:00:00" How can I convert the elements into a valid R date-time constant? Thank you, John John Da

Re: [R] Convert character date time to R date-time variable.

2023-12-07 Thread Ebert,Timothy Aaron
Look at the lubridate package in R. Regards, Tim -Original Message- From: R-help On Behalf Of Sorkin, John Sent: Thursday, December 7, 2023 11:22 AM To: r-help@r-project.org (r-help@r-project.org) Subject: [R] Convert character date time to R date-time variable. [External Email

[R] Convert character date time to R date-time variable.

2023-12-07 Thread Sorkin, John
Colleagues, I have a matrix of character data that represents date and time. The format of each element of the matrix is "2020-09-17_00:00:00" How can I convert the elements into a valid R date-time constant? Thank you, John John David Sorkin M.D., Ph.D. Professor of Medicine, Uni

Re: [R] Date Time, as.POSIXct used locale, strange plot behavior

2021-04-30 Thread Tilmann Faul
Dear Enrico, Thanks a lot, that clarifies the topic for me. Checking the numeric representation i was not aware of. Best Regards Tilmann On 30.04.21 11:17, Enrico Schumann wrote: > On Fri, 30 Apr 2021, Tilmann Faul writes: > >> Dear Jeff, >> >> Thanks for your answer. >> Sys.timezone() gives >

Re: [R] Date Time, as.POSIXct used locale, strange plot behavior

2021-04-30 Thread Enrico Schumann
On Fri, 30 Apr 2021, Tilmann Faul writes: > Dear Jeff, > > Thanks for your answer. > Sys.timezone() gives > [1] "Europe/Berlin" > I tried "Europe/Berlin" as tz argument, giving the same result als using > "CEST" (Central European Summer Time). > It seems to me, that using as.POSIXct without tz ar

Re: [R] Date Time, as.POSIXct used locale, strange plot behavior

2021-04-30 Thread Tilmann Faul
Dear Jeff, Thanks for your answer. Sys.timezone() gives [1] "Europe/Berlin" I tried "Europe/Berlin" as tz argument, giving the same result als using "CEST" (Central European Summer Time). It seems to me, that using as.POSIXct without tz argument defaults to tz UTC and with tz argument, either "CE

Re: [R] Date Time, as.POSIXct used locale, strange plot behavior

2021-04-30 Thread PIKAL Petr
="CET"), 0.3, as.POSIXct("2021-04-21 00:00:00", tz="CET"), 0.2, length=0.07, angle=15) Cheers Petr > -Original Message- > From: R-help On Behalf Of Jeff Newmiller > Sent: Thursday, April 29, 2021 11:20 PM > To: r-hel

Re: [R] Date Time, as.POSIXct used locale, strange plot behavior

2021-04-29 Thread Jeff Newmiller
What is your TZ environment variable set to? That's what time conversion defaults to ?DateTimeClasses Also, I am not sure CEST is a valid timezone designation... it can be system dependent, but using one of the elements listed in ?OlsonNames. On April 29, 2021 12:22:44 PM PDT, Tilmann Faul w

[R] Date Time, as.POSIXct used locale, strange plot behavior

2021-04-29 Thread Tilmann Faul
Hy, stumbled over the following problem while plotting DateTime Objects. plot(as.POSIXct(c("2021-04-21 00:00:00", "2021-04-21 23:59:59")), c(0, 1), type='l') arrows(as.POSIXct("2021-04-21 00:00:00", tz="CEST"), 0.3, as.POSIXct("2021-04-21 00:00:00", tz="CEST"), 0.2, l

[R] Date Time Conversion

2019-05-08 Thread reichmanj
r-Help Community Never mine figured it out just use the "as.POSIXct" function Jeff I need to convert a date-time field (column) but I'm losing the time when I convert using .. tsData <- myData[,10, drop=FALSE] tsData$date_time <- as.Date(tsData$date_time, format="%m/%d/%y %H:%M"

Re: [R] Date Time Conversion

2019-05-08 Thread Rui Barradas
Hello, as.Date() outputs an object of class "Date", you want an object of class c("POSIXt", "POSIXct"). Use as.POSIXct(). Hope this helps, Rui Barradas Às 16:04 de 08/05/19, reichm...@sbcglobal.net escreveu: r-Help Community I need to convert a date-time field (column) but I'm losing

[R] Date Time Conversion

2019-05-08 Thread reichmanj
r-Help Community I need to convert a date-time field (column) but I'm losing the time when I convert using .. tsData <- myData[,10, drop=FALSE] tsData$date_time <- as.Date(tsData$date_time, format="%m/%d/%y %H:%M") head(tsData) date_time 1 2013-06-20

Re: [R] R Date Time

2017-04-25 Thread Dirk Eddelbuettel
On 25 April 2017 at 18:05, Duncan Murdoch wrote: | On 25/04/2017 5:41 PM, Dirk Eddelbuettel wrote: | > | > On 25 April 2017 at 16:04, Jeff Reichman wrote: | > | R Users | > | | > | Having problems converting the following DTG into an R recognized date/time | > | field | > | | > | 01-01-2016T14:02

Re: [R] R Date Time

2017-04-25 Thread Duncan Murdoch
On 25/04/2017 5:41 PM, Dirk Eddelbuettel wrote: On 25 April 2017 at 16:04, Jeff Reichman wrote: | R Users | | Having problems converting the following DTG into an R recognized date/time | field | | 01-01-2016T14:02:23.325 | | Would I separate it into a date field and time filed then put it back

Re: [R] R Date Time

2017-04-25 Thread Dirk Eddelbuettel
On 25 April 2017 at 16:04, Jeff Reichman wrote: | R Users | | Having problems converting the following DTG into an R recognized date/time | field | | 01-01-2016T14:02:23.325 | | Would I separate it into a date field and time filed then put it back | together??? The anytime package (on CRAN) do

Re: [R] R Date Time

2017-04-25 Thread William Dunlap via R-help
> z <- as.POSIXct("01-01-2016T14:02:23.325", format="%d-%m-%YT%H:%M:%OS") > dput(z) structure(1451685743.325, class = c("POSIXct", "POSIXt"), tzone = "") > z [1] "2016-01-01 14:02:23 PST" > format(z, "%H:%M:%OS3 on %b %d, %Y") [1] "14:02:23.325 on Jan 01, 2016" (Don't separate the date and time pa

Re: [R] R Date Time

2017-04-25 Thread Duncan Murdoch
On 25/04/2017 5:04 PM, Jeff Reichman wrote: R Users Having problems converting the following DTG into an R recognized date/time field 01-01-2016T14:02:23.325 Would I separate it into a date field and time filed then put it back together??? This appears to work (though I'm not sure whe

[R] R Date Time

2017-04-25 Thread Jeff Reichman
R Users Having problems converting the following DTG into an R recognized date/time field 01-01-2016T14:02:23.325 Would I separate it into a date field and time filed then put it back together??? Jeff [[alternative HTML version deleted]] __

Re: [R] Date Time in R

2016-07-26 Thread Shivi Bhatia
2:16 PM >>>>> > *To:* Tom Wright >>>>> > *Cc:* David L Carlson ; r-help < >>>>> r-help@r-project.org> >>>>> >>>>> > >>>>> > *Subject:* Re: [R] Date Time in R >>>>> > >&

Re: [R] Date Time in R

2016-07-26 Thread William Dunlap via R-help
> >>>> > >>>> > Please find the details: (i have changed name from eir to a1, rest >>>> all is >>>> > same) >>>> > >>>> > >>>> > >>>> > str(a1$date) >>>> > >>&

Re: [R] Date Time in R

2016-07-26 Thread Shivi Bhatia
;>> > >>> > # extract the weekdays as number >>> > >>> > weekdays <- wday(a1$date) >>> > >>> > >>> > >>> > # note can’t have spaces in variable names >>> > >>> > week_names <- wda

Re: [R] Date Time in R

2016-07-26 Thread Shivi Bhatia
by >> default >> > >> > # so no need for the mdy() or ymd() function >> > >> > >> > >> > # extract the weekdays as number >> > >> > weekdays <- wday(a1$date) >> > >> > >> > >> >

Re: [R] Date Time in R

2016-07-26 Thread William Dunlap via R-help
names > > > > week_names <- wday(a1$date, label=TRUE) > > > > > > > > > > > > *From:* Shivi Bhatia [mailto:shivipm...@gmail.com] > > *Sent:* July 26, 2016 12:16 PM > > *To:* Tom Wright > > *Cc:* David L Carlson ; r-help >

Re: [R] Date Time in R

2016-07-26 Thread Shivi Bhatia
gt; > > > *From:* Shivi Bhatia [mailto:shivipm...@gmail.com] > *Sent:* July 26, 2016 12:16 PM > *To:* Tom Wright > *Cc:* David L Carlson ; r-help > > *Subject:* Re: [R] Date Time in R > > > > Hello Tom, > > > > Please find the details: (i have change

Re: [R] Date Time in R

2016-07-26 Thread Tom Wright
- wday(a1$date) # note can’t have spaces in variable names week_names <- wday(a1$date, label=TRUE) *From:* Shivi Bhatia [mailto:shivipm...@gmail.com] *Sent:* July 26, 2016 12:16 PM *To:* Tom Wright *Cc:* David L Carlson ; r-help *Subject:* Re: [R] Date Time in R Hello Tom, Please

Re: [R] Date Time in R

2016-07-26 Thread Shivi Bhatia
rmation before doing any processing on the date > (i.e. before the as.Date() function) we may be able to help. > > > > -Original Message- > From: R-help [mailto:r-help-boun...@r-project.org] On Behalf Of Shivi > Bhatia > Sent: July 26, 2016 11:46 AM > To: David L Ca

Re: [R] Date Time in R

2016-07-26 Thread Hadley Wickham
; relevant in this context. > > On Tue, Jul 26, 2016 at 8:55 PM, David L Carlson wrote: > >> Show us the output, don’t just tell us what you are seeing. If the dates >> are correct in the csv file, show us the structure of the data frame you >> created with read.csv() an

Re: [R] Date Time in R

2016-07-26 Thread Tom Wright
-help-boun...@r-project.org] On Behalf Of Shivi Bhatia Sent: July 26, 2016 11:46 AM To: David L Carlson Cc: r-help Subject: Re: [R] Date Time in R Hi David please see the code and some reproducible data: eir$date<- as.Date(eir$date,format = "%m-%d-%y") then i had used the lubridate li

Re: [R] Date Time in R

2016-07-26 Thread Shivi Bhatia
n this context. > > On Tue, Jul 26, 2016 at 8:55 PM, David L Carlson > wrote: > >> Show us the output, don’t just tell us what you are seeing. If the dates >> are correct in the csv file, show us the structure of the data frame you >> created with read.csv() and show

Re: [R] Date Time in R

2016-07-26 Thread Shivi Bhatia
the command(s) you used to convert the > character data to date format. The solution is likely to be simple if you > will cut/paste the R console and not just describe what is happening. > > > > David C > > > > *From:* Shivi Bhatia [mailto:shivipm...@gmail.com] >

Re: [R] Date Time in R

2016-07-26 Thread Nordlund, Dan (DSHS/RDA)
om: R-help [mailto:r-help-boun...@r-project.org] On Behalf Of Shivi > Bhatia > Sent: Tuesday, July 26, 2016 4:43 AM > To: Duncan Murdoch > Cc: r-help@r-project.org > Subject: Re: [R] Date Time in R > > Thanks Duncan for the quick response. I will check again as you suggested

Re: [R] Date Time in R

2016-07-26 Thread David L Carlson
will cut/paste the R console and not just describe what is happening. David C From: Shivi Bhatia [mailto:shivipm...@gmail.com] Sent: Tuesday, July 26, 2016 10:08 AM To: David L Carlson Subject: Re: [R] Date Time in R Hi David, This gives the results accurately. The first line shows all the variable

Re: [R] Date Time in R

2016-07-26 Thread David L Carlson
Anthropology Texas A&M University College Station, TX 77840-4352 -Original Message- From: R-help [mailto:r-help-boun...@r-project.org] On Behalf Of Shivi Bhatia Sent: Tuesday, July 26, 2016 7:42 AM To: Marc Schwartz Cc: R-help Subject: Re: [R] Date Time in R Thanks Marc for the help. thi

Re: [R] Date Time in R

2016-07-26 Thread Shivi Bhatia
Thanks Marc for the help. this really helps. I think there is some issue with the data saved in csv format for this variable as when i checked: str(eir$date)- this results in :- Date[1:5327], format: NA NA NA NA NA. Thanks again. On Tue, Jul 26, 2016 at 5:58 PM, Marc Schwartz wrote: > Hi, > > T

Re: [R] Date Time in R

2016-07-26 Thread Marc Schwartz
Hi, That eir$date might be a factor is irrelevant. There is an as.Date() method for factors, which does the factor to character coercion internally and then calls as.Date.character() on the result. Using the example data below: eir <- data.frame(date = c("05-30-16", "05-30-16", "05-30-16",

Re: [R] Date Time in R

2016-07-26 Thread Shivi Bhatia
Hello Again, While i tried your solution as you suggested above it seems to be working. Here is the output temp<- dput(head(eir$date)) c("05-30-16", "05-30-16", "05-30-16", "05-30-16", "05-30-16", "05-30-16") however it still shows class(eir$date) as character and hence i cannot find weekdays from

Re: [R] Date Time in R

2016-07-26 Thread Shivi Bhatia
Thanks Duncan for the quick response. I will check again as you suggested. If that doesn't work i will share a reproducible example. Thanks again On Tue, Jul 26, 2016 at 4:43 PM, Duncan Murdoch wrote: > On 26/07/2016 7:05 AM, Shivi Bhatia wrote: > >> Hi Team, >> >> This scenario may have co

Re: [R] Date Time in R

2016-07-26 Thread Duncan Murdoch
On 26/07/2016 7:05 AM, Shivi Bhatia wrote: Hi Team, This scenario may have come across a number of times however i checked nabble & SO and couldn't find a solution hence request assistance. I have a date variable in my data-set eir. The class of this var was character while i had read the file

[R] Date Time in R

2016-07-26 Thread Shivi Bhatia
Hi Team, This scenario may have come across a number of times however i checked nabble & SO and couldn't find a solution hence request assistance. I have a date variable in my data-set eir. The class of this var was character while i had read the file in r studio. Example of date - 05-30-16 To c

Re: [R] date time problem

2014-12-08 Thread Jeff Newmiller
You are still posting in HTML, and it is continuing to impede this conversation. Learn how to post in plain text before posting again. Gmail does have this option. You are not using dput, as previously asked, either. Read the web page I referenced to learn how to send R data unambiguously. Y

Re: [R] date time problem

2014-12-07 Thread Alemu Tadesse
Thank you very much Jeff. Below is the data I used: > Corrected_data SA_LST SA_GHI_mean 61759 3/11/2007 1:00 0.0 67517 3/11/2007 2:00 0.0 70017 3/11/2007 3:00 0.0 70524 3/11/2007 4:00 0.0 71061 3/11/2007 5:00 0.0 71638 3/11/2007 6:00 0.0

Re: [R] date time problem

2014-12-07 Thread Jeff Newmiller
You have not provided a reproducible example, so anything I say could be wrong just due to misinterpretation. Please read [1] for suggestions on making your examples reproducible, particularly regarding the use of dput to provide example data. You have also posted in HTML format, which can caus

Re: [R] date time problem

2014-12-07 Thread jim holtman
I would use the 'lubridate' package for this: > z <- Sys.time() > z [1] "2014-12-07 15:43:50 EST" > require(lubridate) > with_tz(z, "UTC") [1] "2014-12-07 20:43:50 UTC" Jim Holtman Data Munger Guru What is the problem that you are trying to solve? Tell me what you want

[R] date time problem

2014-12-07 Thread Alemu Tadesse
Dear R users I am puzzled by the following result from R script. I am trying to convert local time to UTC time. Time zone is -5, therefore I used the following approach. Below is the script. > Corrected_SA_data$date_time[k-1] [1] "2007-03-11 01:00:00" > Corrected_SA_data$TZ[k-1] [1] -5 > Correcte

Re: [R] date & time manipulation- R 2.15.1 windows 7

2013-03-18 Thread yash kajaria
) > date2<-"2013-01-26" > wday(ymd(date2),label=TRUE) > # 1 parsed with %Y-%m-%d > #[1] Sat > > > week(ymd(date2)) > # 1 parsed with %Y-%m-%d > #[1] 4 > A.K. > > ----- Original Message - > From: yash kajaria > To: r-help@r-project.org >

Re: [R] date & time manipulation- R 2.15.1 windows 7

2013-03-14 Thread arun
t.org Cc: Sent: Thursday, March 14, 2013 9:45 AM Subject: [R] date & time manipulation- R 2.15.1 windows 7 Hi,     I wanted to learn how to solve a date and time manipulation where i can do the following two     1. difference of two dates eg (differnce between 5th jan 2013 and 1st jan 2013)  

Re: [R] date & time manipulation- R 2.15.1 windows 7

2013-03-14 Thread Gabor Grothendieck
On Thu, Mar 14, 2013 at 9:45 AM, yash kajaria wrote: > Hi, > I wanted to learn how to solve a date and time manipulation where i can > do the following two > 1. difference of two dates eg (differnce between 5th jan 2013 and 1st > jan 2013) > > 2.Suppose i have week number of the year,

Re: [R] date & time manipulation- R 2.15.1 windows 7

2013-03-14 Thread John Kane
-project.org > Subject: [R] date & time manipulation- R 2.15.1 windows 7 > > Hi, > I wanted to learn how to solve a date and time manipulation where i > can > do the following two > 1. difference of two dates eg (differnce between 5th jan 2013 and 1st > jan 2013) >

[R] date & time manipulation- R 2.15.1 windows 7

2013-03-14 Thread yash kajaria
Hi, I wanted to learn how to solve a date and time manipulation where i can do the following two 1. difference of two dates eg (differnce between 5th jan 2013 and 1st jan 2013) 2.Suppose i have week number of the year, i want to know if i can find out the day it refers to eg( say week

[R] date-time series plot

2012-04-02 Thread mpavlic
Hi all, i have a date-time series plot like this : Datum-Ura;padavine;P-kum-15dni;BLPV-1N;T-BLPV-1N;BLPV-4N;T-BLPV-4N;BLPV-5N;T-BLPV-5N;pretok;N-min;N-max 1.1.2011 18:00;0.0;0.0;174.62;14.60;174.56;14.10;174.64;14.20;299.26;174.18;181.78 2.1.2011 0:00;0.0;0.0;174.60;14.60;174.60;14.10;174.64;14.2

Re: [R] Date/time

2012-01-14 Thread Gabor Grothendieck
On Sat, Jan 14, 2012 at 4:35 AM, claire5 wrote: > I have been trying for some time to nicely plot some of my data, I have > around 1800 values for some light intensity, taken every hour of the day > over almost 2 months. > > My data file looks like: > >     Date    Time. GMT.02.00 Intensity > 1  

Re: [R] Date/time

2012-01-14 Thread claire5
Well, I am not sure how to use the zoo package to be honest. I am trying to plot all 1800 data in the same graph but of course it looks super messy. And R does not really recognize the time data input. so i just want to plot the time series kind of. The problem is that the x value is date and time

Re: [R] Date/time

2012-01-14 Thread R. Michael Weylandt
What exactly is your problem? People quite like the "zoo" package for handling and plotting time series: perhaps that will work for you? Michael On Sat, Jan 14, 2012 at 4:35 AM, claire5 wrote: > Hey guys, > > I have been trying for some time to nicely plot some of my data, I have > around 1800 v

[R] Date/time

2012-01-14 Thread claire5
Hey guys, I have been trying for some time to nicely plot some of my data, I have around 1800 values for some light intensity, taken every hour of the day over almost 2 months. My data file looks like: DateTime. GMT.02.00 Intensity 106.10.11 11:00:00AM x 206.10.11

Re: [R] Date-time Conversion from Numeric Representations

2010-12-03 Thread Uwe Ligges
On 03.12.2010 16:31, Alexander Salim wrote: Hi all, I have a dataset called ,dataSet1'. The time column is given in a numeric code beginning with the year and ending with the minutes. Frist I tried the strptime() function to solve the problem. It gave me just the date back (and not the date an

[R] Date-time Conversion from Numeric Representations

2010-12-03 Thread Alexander Salim
Hi all, I have a dataset called ,dataSet1'. The time column is given in a numeric code beginning with the year and ending with the minutes. Frist I tried the strptime() function to solve the problem. It gave me just the date back (and not the date and time). There is also the ISOdatetime function

Re: [R] Date Time Objects

2010-10-13 Thread dpender
Perfect. Thanks -- View this message in context: http://r.789695.n4.nabble.com/Date-Time-Objects-tp2993524p2993663.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinf

Re: [R] Date Time Objects

2010-10-13 Thread Henrique Dallazuanna
Try this: sapply(0::(length(DateTime3)-1), function(i)format(strptime(start, "%m/%d/%Y %H:%M") + i * interval, "%Y-%m-%d %H:%M:%S")) On Wed, Oct 13, 2010 at 10:16 AM, dpender wrote: > > Thanks Henrique, > > Do you have any idea why the first entry doesn't have the time as the start > specifie

Re: [R] Date Time Objects

2010-10-13 Thread dpender
Thanks Henrique, Do you have any idea why the first entry doesn't have the time as the start specified is "1/1/1981 00:00"? Is it something to do with being at midnight? Doug -- View this message in context: http://r.789695.n4.nabble.com/Date-Time-Objects-tp2993524p2993640.html Sent from the

Re: [R] Date Time Objects

2010-10-13 Thread Henrique Dallazuanna
Try this: sapply(0:(length(DateTime3)-1), function(i)as.character(strptime(start, "%m/%d/%Y %H:%M") + i * interval)) On Wed, Oct 13, 2010 at 8:51 AM, dpender wrote: > > I am trying to convert an array from numeric values back to date and time > format. The code I have used is as follows; > >

[R] Date Time Objects

2010-10-13 Thread dpender
I am trying to convert an array from numeric values back to date and time format. The code I have used is as follows; for (i in 0:(length(DateTime3)-1)) { DateTime3[i] <- (strptime(start, "%m/%d/%Y %H:%M")+ i*interval) where start <- [1] "1/1/1981 00:00" However the created array

[R] Date/Time format

2010-09-27 Thread Costas
Hello, Is it possible to instruct (permanently) R to write on csv (and read from csv) time series, where the time stamp has a particular format: say: -mm-dd i.e., as in format(Sys.Date(), "%Y-%m-%d") Many thanks in advance, Costas __ R-help

Re: [R] Date-Time-Stamp input method for user-specific formats

2009-10-06 Thread esp
Another solution, as a fix to my original algorithm, was found by a colleague (Matthew Roberts). While he claims not too much for its elegance, it does seem to work. This fix is based on the use of the 'pmax' function. This function is a variant of the 'max' (maximum) function to return a vecto

Re: [R] Date-Time-Stamp input method for user-specific formats

2009-10-06 Thread esp
esp wrote: > > For the function as defined above using 'sapply' >> spot[,1] > 01/09/2009 01/09/2009 00:00:01 01/09/2009 00:00:02 01/09/2009 > 00:00:03 > 1251759600 1251759601 1251759602 > 1251759603 > > This was unexpected - it seems to have display

Re: [R] Date-Time-Stamp input method for user-specific formats

2009-10-06 Thread Gabor Grothendieck
See below. On Mon, Oct 5, 2009 at 6:50 PM, Gabor Grothendieck wrote: > Try this.  First we read a line at a time into L except for the > header.  Then we use strapply to match on the given pattern.  It > passes the backreferences (the portions within parentheses in the > pattern) to the function

Re: [R] Date-Time-Stamp input method for user-specific formats

2009-10-06 Thread esp
Thank you all who replied, I will try out these ideas later today. David Esp -- View this message in context: http://www.nabble.com/Date-Time-Stamp-input-method-for-user-specific-formats-tp25757018p25763935.html Sent from the R help mailing list archive at Nabble.com. ___

Re: [R] Date-Time-Stamp input method for user-specific formats

2009-10-05 Thread Gabor Grothendieck
Try this. First we read a line at a time into L except for the header. Then we use strapply to match on the given pattern. It passes the backreferences (the portions within parentheses in the pattern) to the function (defined via a formula) whose implicit arguments are x, y and z. That function

Re: [R] Date-Time-Stamp input method for user-specific formats

2009-10-05 Thread David Winsemius
On Oct 5, 2009, at 5:14 PM, esp wrote: Date-Time-Stamp input method to correctly interpret user-specific formats:coding is 90% there - based on exmple at http://tolstoy.newcastle.edu.au/R/help/05/02/12003.html ...anyone got the last 10% please? CONTEXT: Data is received where one of the col

Re: [R] Date-Time-Stamp input method for user-specific formats

2009-10-05 Thread Don MacQueen
Off the top of my head, I think you're working to hard at this. I would read in the timestamp column as a character string. Then, find those where the string length is too short [using nchar()], append "00:00:00" to those [using paste()], and then convert to POSIXt [using as.POSIXct()]. No

[R] Date-Time-Stamp input method for user-specific formats

2009-10-05 Thread esp
Date-Time-Stamp input method to correctly interpret user-specific formats:coding is 90% there - based on exmple at http://tolstoy.newcastle.edu.au/R/help/05/02/12003.html ...anyone got the last 10% please? CONTEXT: Data is received where one of the columns is a datetimestamp. At midnight, th

Re: [R] Date/Time to date & time

2009-09-20 Thread Mark Knecht
On Sun, Sep 20, 2009 at 1:55 PM, Gabor Grothendieck wrote: > On Sun, Sep 20, 2009 at 4:52 PM, Mark Knecht wrote: >> Thanks Gabor, >>   I did try to use dput but it wasn't cooperating and wanted to send >> FAR too much data. > > dput(head(x, 10)) > As I said, I tried almost exactly that. I didn't

Re: [R] Date/Time to date & time

2009-09-20 Thread Gabor Grothendieck
On Sun, Sep 20, 2009 at 4:52 PM, Mark Knecht wrote: > Thanks Gabor, >   I did try to use dput but it wasn't cooperating and wanted to send > FAR too much data. dput(head(x, 10)) > >   Your method works well for me but as I look at it I don't > understand the use of double brackets - DF[[1]] - wh

Re: [R] Date/Time to date & time

2009-09-20 Thread Mark Knecht
Thanks Gabor, I did try to use dput but it wasn't cooperating and wanted to send FAR too much data. Your method works well for me but as I look at it I don't understand the use of double brackets - DF[[1]] - why do you do that? Anyway, thanks for the fast reponses from you and Jim. Both

Re: [R] Date/Time to date & time

2009-09-20 Thread Gabor Grothendieck
Note that your explanation refers to strptime but the code uses strftime which accounts for the error. Try this: > Lines <- "ENTRY DATE + 3/23/2009 6:30:00 AM + 3/23/2009 6:30:00 AM + 3/23/2009 6:39:00 AM + 3/23/2009 6:39:00 AM + 3/23/2009 6:48:00 AM + 3/23/2009 6:48:00 AM + 3/23/2009 7:00:00 AM"

Re: [R] Date/Time to date & time

2009-09-20 Thread jim holtman
Here is one way to do it. Not sure why you want columns with either date or time since you already have them. This will create a POSIXct object you can use for processing and then two character columns with date and time. Exactly what are you going to do with the data. > str(x) 'data.frame':

[R] Date/Time to date & time

2009-09-20 Thread Mark Knecht
Hi, Can strptime (or some other function) help me turn the following column of a data.frame into two new columns, one as date and the other as time, preserving the AM/PM value? Thanks, Mark > B ENTRY DATE 1 3/23/2009 6:30:00 AM 2 3/23/2009 6:30:00 AM 3 3/23/2009 6:39:00 AM 4

Re: [R] Date Time conversion

2008-09-26 Thread Gabor Grothendieck
chron uses: - separate arguments for date and time -- not a single one as you have - a separate system for the codes, not the % codes of Date and POSIXt classes If you want to specify the date and time all as one string rather than two arguments, use as.chron instead of chron -- as.chron does use

[R] Date Time conversion

2008-09-26 Thread stephen sefick
what am I doing wrong? chron(as.character(f), format=c(dates="%m/%d/%y", times="%h:%m")) f <- structure(c(51L, 60L, 66L, 87L, 90L, 115L, 23L, 35L, 37L, 6L, 12L, 55L, 84L, 96L, 109L, 17L, 29L, 41L, 3L, 74L, 94L, 102L, 30L, 8L, 46L, 69L, 107L, 15L, 25L, 39L, 1L, 71L, 95L, 19L, 56L, 62L, 76L, 85L, 9

Re: [R] Date Time Sequence

2008-06-26 Thread stephen sefick
Gabor this is better than using x = seq(ISOdate(2006,1,1, 0, 0, 0), by = "15 min", length.out=35040) this works but your code below is exactly what I needed instead of almost. thankyou very much Stephen On Thu, Jun 26, 2008 at 6:06 PM, Gabor Grothendieck <[EMAIL PROTECTED]> wrote: > Try this:

Re: [R] Date Time Sequence

2008-06-26 Thread Gabor Grothendieck
Try this: library(chron) t1 <- chron("1/1/2006", "00:00:00") t2 <- chron("12/31/2006", "23:45:00") deltat <- times("00:15:00") tt <- seq(t1, t2, by = times("00:15:00")) Note that if you have some data and your intention is simply to create the index for it so you can create a zoo or zooreg object

[R] Date Time Sequence

2008-06-26 Thread stephen sefick
I would like a sequence of dates with a time step of 15 minutes starting: 1/1/2006 00:00:00 - 12/31/2006 23:45:00 function(x) { chron(sub(" .*", "", x), gsub(".* (.*)", "\\1:00", x)) } this is the piece of code I use to read in zoo objects for any help I would be grateful I have tried sequenc

[R] Date time, MSSQL and RODBC

2008-01-31 Thread Daniele Amberti
Hi, I have to connect to MSSQL server to get some TimeSeries value (datetime, float) on output. Datetime data type in R is a POSIXct date with information about timezone, daylight or solar time. In the DB I have not this kind of information and this cause some problem at the change of time for e