'Withdraw second response when a first response is doubled

I have a vector consisting in a digital suite of values in ms :

vect = c(450, 649, 1900, 2200, 3050, 3090)

I would like the timelag between N and N+1 be shorter than 200 ms and if it were not the case, transform N+1 into NA. Here for instance, it would transform value 649 ms and value 3090 ms into NAs. How can I do that ?

Thanks a lot for your help



Solution 1:[1]

look these functions up: Ifelse() and lead() or lag(). Or if_else() to force consistent result types.

Solution 2:[2]

I'm a bit confused by your description but I think this is what you mean:

vect = c(450, 649, 1900, 2200, 3050, 3090)

vect_diff <- vect |> 
  diff() |>
  {\(x) c(0, x)}()

vect_replaced <- ifelse(
  vect_diff < 200,
  vect,
  NA_integer_
)

Solution 3:[3]

Need to update cocoa pods to the latest version run: pod install

Solution 4:[4]

Use this command which will remove existing pods and install pod again. This will also remove node_modules and do a fresh install.

rm -rf node_modules && yarn install && cd ios && rm -rf Pods && pod install && cd ..

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Selsheikh
Solution 2 Evan Cutler Anway
Solution 3 Nur-E-Alam Khan
Solution 4 Amit Dutta