Created
May 1, 2019 14:38
-
-
Save phil8192/b9a514dfcc5f76bb48f46f9a39339044 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# convert | |
# 7, 7, 6, 5, 5, 3, 3, 2, 0, 0 -> | |
# 1 1 2 3 3 4 4 5 NA NA | |
x <- c(7,7,6,5,5,3,3,2,0,0) | |
ifelse(x,cumsum(c(1,abs(sign(diff(x))))),NA) | |
# [1] 1 1 2 3 3 4 4 5 NA NA |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment