[R] creating a time series

Rui Barradas ru|pb@rr@d@@ @end|ng |rom @@po@pt
Mon Oct 16 12:34:52 CEST 2023


Às 11:12 de 16/10/2023, ahmet varlı escreveu:
> 
> 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.
Hello,

Given your date format, try


format = "%d.%m.%Y %H:%M"


Test with your date time:



x <- "2.11.2017 13:30"
as.POSIXct(x, format = "%d.%m.%Y %H:%M")
#> [1] "2017-11-02 13:30:00 WET"

as.POSIXct(su_seviyeleri_data$kayit_zaman, format = "%d.%m.%Y %H:%M")


Hope this helps,

Rui Barradas


-- 
Este e-mail foi analisado pelo software antivírus AVG para verificar a presença de vírus.
www.avg.com



More information about the R-help mailing list