0

My goal is to create a VMS point density layer of vessels, but the time interval between pings (points) is every 60min for some ships, and for others every 10min, and I want to equate them to the same time scale (60min).

Once I have calculated the time interval between points, my idea would be to eliminate (ideally delete, or transform by NA to delete afterwards) the next four rows (20-50min) every time a 10min record appears.

I've been trying for days with multiple functions (lead, filter, ifelse, etc) but I can't get it, I would be tremendously grateful if someone could help me with this function, please?

These are the 511-550 rows of time intervals (min):

[511] 241 60 60 3508 891 230 10 10 10 10

[521] 10 6190 10 10 10 10 10 10 10 10

[531] 10 9920 10 10 10 10 10 10 10 10

[541] 10 10 -191 141 -422 2027 60 61 61 60`

Applying this:

   `VMStest <- ifelse((VMSpoints21$interval[1: 
    (nrow(VMSpoints21)-1)])==10, lead(c(2:6), n=4), 
    VMSpoints21$interval)`

I got this:

`[511] 241 60 60 3508 891 230 NA NA NA NA

[521] 6 6190 NA NA NA 6 NA NA NA NA

[531] 6 9920 NA NA NA 6 NA NA NA NA

[541] 6 NA -191 141 -422 2027 60 61 61 60`

is super wrong, but it is further I´ve come, please any idea?

Karima
  • 1
  • 1

0 Answers0