[R] creating a time series
Marc Girondot
m@rc_grt @end|ng |rom y@hoo@|r
Mon Oct 16 12:43:42 CEST 2023
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.
More information about the R-help
mailing list