Skip to content

Instantly share code, notes, and snippets.

@danielecook
Last active December 8, 2017 01:03
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save danielecook/1cb76558fda8c01fc85c014afda28b18 to your computer and use it in GitHub Desktop.
Save danielecook/1cb76558fda8c01fc85c014afda28b18 to your computer and use it in GitHub Desktop.
test_df %>%
dplyr::arrange(chromosome, isotype, start, stop) %>%
dplyr::filter(
(!(lead(start) == stop & lead(haplotype) == haplotype & lead(isotype) == isotype & lead(chromosome) == chromosome) | is.na(lag(start)) | is.na(lead(stop)))
) %>%
dplyr::mutate(stop = ifelse(lead(isotype) == isotype &
lead(haplotype) == haplotype &
!is.na(lead(stop)),
lead(stop),
stop)
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment