Re: [R] Change data frame to time series data

2024-10-02 Thread roslinazairimah zakaria
Hi Hasan, Yes, it works beautifully also. Thank you very much ..the simplest ya. On Wed, Oct 2, 2024 at 11:56 PM Hasan Diwan wrote: > > dt_ts['2014-01-01 00:00:00/2014-12-15 23:59:00'] > > Does that work? -- H > > -- > OpenPGP: https://hasan.d8u.us/openpgp.asc > If you wish to request my time,

Re: [R] Change data frame to time series data

2024-10-02 Thread Hasan Diwan
> dt_ts['2014-01-01 00:00:00/2014-12-15 23:59:00'] Does that work? -- H -- OpenPGP: https://hasan.d8u.us/openpgp.asc If you wish to request my time, please do so using *bit.ly/hd1AppointmentRequest *. Si vous voudriez faire connnaisance, allez a *bit.ly/hd1Ap

Re: [R] Change data frame to time series data

2024-10-02 Thread roslinazairimah zakaria
Hi Hasan, Thank you so much for your help. But I got this error. > dt_ts['2014-01-01 00:00:00'::'2014-12-15 23:59:00']Error in loadNamespace(x) : there is no package called ‘2014-01-01 00:00:00’ On Wed, Oct 2, 2024 at 11:36 PM Hasan Diwan wrote: > On Wed, 2 Oct 2024 at 08:20, roslinazairimah

Re: [R] Change data frame to time series data

2024-10-02 Thread roslinazairimah zakaria
Thank you so much Rui, it is very helpful, simple yet works beautifully. from <- as.POSIXct("2014-01-01 00:00:00") to <- as.POSIXct("2014-12-15 23:59:00") i<- index(dt_ts) >= from & index(dt_ts) <= to dt_ts[i] On Wed, Oct 2, 2024 at 11:39 PM Rui Barradas wrote: > Às 16:20 de 02/10/2024, r

Re: [R] Change data frame to time series data

2024-10-02 Thread Rui Barradas
Às 16:20 de 02/10/2024, roslinazairimah zakaria escreveu: Let say, this is my data and I want to extract from 2014-01-01 00:00:00 to 2014-01-01 16:30:00 dput(head(dt_ts,1000)) structure(c(0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0

Re: [R] Change data frame to time series data

2024-10-02 Thread Hasan Diwan
On Wed, 2 Oct 2024 at 08:20, roslinazairimah zakaria wrote: > Let say, this is my data and I want to extract from 2014-01-01 00:00:00 > to 2014-01-01 16:30:00 > > dt_ts['2014-01-01 00:00:00'::'2014-01-01 16:30:00'] Try that? -- OpenPGP: https://hasan.d8u.us/openpgp.asc If you wish to request

Re: [R] Change data frame to time series data

2024-10-02 Thread roslinazairimah zakaria
Let say, this is my data and I want to extract from 2014-01-01 00:00:00 to 2014-01-01 16:30:00 >dput(head(dt_ts,1000)) structure(c(0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L

Re: [R] Change data frame to time series data

2024-10-02 Thread Hasan Diwan
On Wed, 2 Oct 2024 at 07:53, roslinazairimah zakaria wrote: > Next question, how do I delete the date from 16 December until 31 December > 2014? > Something like: myData <- xtsObj[myData$date < "2014-12-16" & myData$date > "2024-12-31"] -- H -- OpenPGP: https://hasan.d8u.us/openpgp.asc If you

Re: [R] Change data frame to time series data

2024-10-02 Thread roslinazairimah zakaria
Hi Enrico, yes it works. I can also plot the graph. Next question, how do I delete the date from 16 December until 31 December 2014? Thank you very much. > dt$time <- as.POSIXct(dt$time)> > dt_ts <- xts(dt$count, dt$time)> > str(dt_ts)An xts object on 2014-01-01 / 2014-12-31 23:59:00 containing

Re: [R] Change data frame to time series data

2024-10-02 Thread Enrico Schumann
On Wed, 02 Oct 2024, roslinazairimah zakaria writes: > Dear all, I have a data in data frame and would like to change to time > series data. Thank you for any help given. > >> str(dt)'data.frame': 525600 obs. of 3 variables: > $ time : chr "2014-01-01 00:00:00" "2014-01-01 00:01:00"

[R] Change data frame to time series data

2024-10-01 Thread roslinazairimah zakaria
Dear all, I have a data in data frame and would like to change to time series data. Thank you for any help given. > str(dt)'data.frame': 525600 obs. of 3 variables: $ time : chr "2014-01-01 00:00:00" "2014-01-01 00:01:00" "2014-01-01 00:02:00" "2014-01-01 00:03:00" ... $ cnt_