first_which <- function(expr) {
o <- which(expr)
if (length(o)) {
return(o[1])
} else {
return(0L)
}
}
last_which <- function(expr) {
o <- which(expr)
if (length(o)) {
return(last(o))
} else {
return(0L)
}
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.