R-users, I have two vectors (of timestamps)
d1 <- as.POSIXct(strptime("2.2.2002 07:00", format="%d.%m.%Y %H:%M")) d2 <- as.POSIXct(strptime("4.2.2002 07:00", format="%d.%m.%Y %H:%M")) seq1 <- seq(d1, d2, "hours") seq1 d3 <- as.POSIXct(strptime("2.2.2002 15:22", format="%d.%m.%Y %H:%M")) d4 <- as.POSIXct(strptime("3.2.2002 18:12", format="%d.%m.%Y %H:%M")) seq2 <- seq(d3, d4, "hours") seq2 How to select timestamps from seq1 which are just before and after of particular timestamp in seq2? The resulting vector should look like this in this example: "2002-02-02 15:00:00 Normaaliaika" "2002-02-02 16:00:00 Normaaliaika" "2002-02-02 16:00:00 Normaaliaika" "2002-02-02 17:00:00 Normaaliaika" "2002-02-02 17:00:00 Normaaliaika" "2002-02-02 18:00:00 Normaaliaika" "2002-02-02 18:00:00 Normaaliaika" etc. Thank you, Lauri > sessionInfo() R version 2.6.0 (2007-10-03) i386-pc-mingw32 locale: LC_COLLATE=Finnish_Finland.1252;LC_CTYPE=Finnish_Finland.1252;LC_MONETARY=Finnish_Finland.1252;LC_NUMERIC=C;LC_TIME=Finnish_Finland.1252 attached base packages: [1] stats graphics grDevices utils datasets methods base other attached packages: [1] RODBC_1.2-3 loaded via a namespace (and not attached): [1] tools_2.6.0 ______________________________________________ R-help@r-project.org mailing list 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.