[R] Ynt: creating a time series

Jeff Newmiller jdnewm|| @end|ng |rom dcn@d@v|@@c@@u@
Mon Oct 16 17:00:59 CEST 2023


Then your data has extra data points... either duplicates or records with timestamps not on 15min intervals.


On October 16, 2023 7:29:25 AM PDT, "ahmet varlı" <varli61 using windowslive.com> wrote:
>hello,
>
>because ı have data between these times and it has 177647 elements
>________________________________
>Gönderen: Marc Girondot via R-help <r-help using r-project.org> adına R-help <r-help-bounces using r-project.org>
>Gönderildi: 16 Ekim 2023 Pazartesi 13:43
>Kime: r-help using r-project.org <r-help using r-project.org>
>Konu: Re: [R] creating a time series
>
>Why did you expect to have 177647 elements ?
>
>I found that 177642 is the correct number:
>
>Marc
>
>baslangic <- as.POSIXct("2017-11-02 13:30:00", tz = "CET")
>bitis <- as.POSIXct("2022-11-26 23:45:00", tz = "CET")  #
>zaman_seti <- seq.POSIXt(from = baslangic, to = bitis, by = 60 * 15)
>
>y2017_11_02 <- seq(from=as.POSIXct("2017-11-02 13:30:00", tz = "CET"),
>to=as.POSIXct("2017-11-02 23:45:00", tz = "CET"), by = 60 * 15)
># Length 42 - OK
>length(y2017_11_02)
>y2017_11_12 <- seq(from=as.POSIXct("2017-11-03 00:00:00", tz = "CET"),
>to=as.POSIXct("2017-12-31 23:45:00", tz = "CET"), by = 60 * 15)
># ((30-2)+31)*24*4=5664 - OK
>length(y2017_11_12)
>y2018 <- seq(from=as.POSIXct("2018-01-01 00:00:00", tz = "CET"),
>to=as.POSIXct("2018-12-31 23:45:00", tz = "CET"), by = 60 * 15)
># (365)*24*4=35040 - OK
>length(y2018)
>y2019 <- seq(from=as.POSIXct("2019-01-01 00:00:00", tz = "CET"),
>to=as.POSIXct("2019-12-31 23:45:00", tz = "CET"), by = 60 * 15)
># (365)*24*4=35040 - OK
>length(y2019)
>y2020 <- seq(from=as.POSIXct("2020-01-01 00:00:00", tz = "CET"),
>to=as.POSIXct("2020-12-31 23:45:00", tz = "CET"), by = 60 * 15)
># (366)*24*4=35136 - OK
>length(y2020)
>y2021 <- seq(from=as.POSIXct("2021-01-01 00:00:00", tz = "CET"),
>to=as.POSIXct("2021-12-31 23:45:00", tz = "CET"), by = 60 * 15)
># (365)*24*4=35040 - OK
>length(y2021)
>y2022 <- seq(from=as.POSIXct("2022-01-01 00:00:00", tz = "CET"),
>to=as.POSIXct("2022-11-26 23:45:00", tz = "CET"), by = 60 * 15)
># (365-31-4)*24*4=31680 - OK
>length(y2022)
>
>length(y2017_11_02)+length(y2017_11_12)+length(y2018)+length(y2019)+length(y2020)+length(y2021)+length(y2022)
>length(zaman_seti)
>
>
>Le 16/10/2023 à 12:12, ahmet varlı a écrit :
>> Hello everyone,
>>
>> � had 15 minutes of data from 2017-11-02 13:30:00 to  2022-11-26 23:45:00 and number of data is 177647
>>
>> � would like to ask why my time series are less then my expectation.
>>
>>
>> baslangic <- as.POSIXct("2017-11-02 13:30:00", tz = "CET")
>> bitis <- as.POSIXct("2022-11-26 23:45:00", tz = "CET")  #
>> zaman_seti <- seq.POSIXt(from = baslangic, to = bitis, by = 60 * 15)
>>
>>
>> length(zaman_seti)
>> [1] 177642
>>
>> but it has to be  177647
>>
>>
>>
>> and secondly � have times in this format ( 2.11.2017 13:30/DD-MM-YYYY HH:MM:SS)
>>
>> su_seviyeleri_data <- as.POSIXct(su_seviyeleri_data$kayit_zaman, format = "%Y-%m-%d %H:%M:%S")
>>
>> I am using this code to change the format but it gives result as Na
>>
>> How can � solve this problem?
>>
>> Bests,
>>
>>
>>
>>
>>
>>        [[alternative HTML version deleted]]
>>
>>
>> ______________________________________________
>> R-help using r-project.org mailing list -- To UNSUBSCRIBE and more, see
>> 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 using r-project.org mailing list -- To UNSUBSCRIBE and more, see
>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.
>
>	[[alternative HTML version deleted]]
>
>______________________________________________
>R-help using r-project.org mailing list -- To UNSUBSCRIBE and more, see
>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.

-- 
Sent from my phone. Please excuse my brevity.



More information about the R-help mailing list