GithubHelp home page GithubHelp logo

Comments (1)

Joaobazzo avatar Joaobazzo commented on July 28, 2024

my idea

library(data.table)
library(magrittr)
# data
dt <- c("00:00:01","01:34:15","03:40:29","05:25:44","07:40:58","08:49:12",
        "10:31:26","12:19:40","14:21:55","15:42:09","17:22:23","19:27:37",
        "21:20:52","22:08:06","00:33:20","00:38:25") %>% data.table::as.ITime()
# analysis
aux <- as.numeric(dt)
aux1 <- shift(aux,n = 1, fill = 0,type = "lag")
diff <- aux - aux1  # difference
diff
#>  [1]      1   5654   7574   6315   8114   4094   6134   6494   7335   4814
#> [11]   6014   7514   6795   2834 -77686    305

# from position in which diff is negative until the last position
mod <- which(diff < 0):length(diff)
mod
#> [1] 15 16

# add one day (86400 s)
dt[mod] = 86400 + dt[mod] 
dt
#>  [1] "00:00:01" "01:34:15" "03:40:29" "05:25:44" "07:40:58" "08:49:12"
#>  [7] "10:31:26" "12:19:40" "14:21:55" "15:42:09" "17:22:23" "19:27:37"
#> [13] "21:20:52" "22:08:06" "24:33:20" "24:38:25"
dt <- as.numeric(dt)
dt
#>  [1]     1  5655 13229 19544 27658 31752 37886 44380 51715 56529 62543 70057
#> [13] 76852 79686 88400 88705

Created on 2020-05-14 by the reprex package (v0.3.0)

from gtfs2gps.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.