Skip to content

Instantly share code, notes, and snippets.

@erzk
Last active April 12, 2018 20:27
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 erzk/9a360692db54e9f1bdacbe29e7dd3743 to your computer and use it in GitHub Desktop.
Save erzk/9a360692db54e9f1bdacbe29e7dd3743 to your computer and use it in GitHub Desktop.
# define a function
replace_nth_ETG4000 <- function(x, mark) {
x <- x %>% group_by(Mark) %>% mutate(Count = row_number()) %>% data.frame()
double_marks <- which(x$Mark == mark & x$Count %% 2 == 0)
x$Mark[double_marks] <- 0
x <- subset(x, select = -Count)
return(x)
}
# remove second occurrence of Mark 2
df2 <- replace_nth_ETG4000(df, 2)
df2 <- replace_nth_ETG4000(df2, 2)
# reassign block borders
block_borders <- which(df2$Mark == 2)
# plot
plot(df2$CH1.703.6., type = "l", ylab = "Intensity")
abline(v = block_borders, col = "blue")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment