#' @title Convert to seconds
#'
#' @description For infiltration times listed as character strings with the format HH:MM:SS return just seconds
#'
#' @param x
#'
#' @return Time in seconds
#'
#' @examples toSeconds("01:12:15)
#'
#' @export toSeconds
#'
#'
# Some useful keyboard shortcuts for package authoring:
#
# Build and Reload Package: 'Ctrl + Shift + B'
# Check Package: 'Ctrl + Shift + E'
# Test Package: 'Ctrl + Shift + T'
toSeconds <- function(x){
if (!is.character(x)) stop("x must be a character string of the form H:M:S")
if (length(x)<=0)return(x)
unlist(
lapply(x,
function(i){
i <- as.numeric(strsplit(i,':',fixed=TRUE)[[1]])
if (length(i) == 3)
i[1]*3600 + i[2]*60 + i[3]
else if (length(i) == 2)
i[1]*60 + i[2]
else if (length(i) == 1)
i[1]
}
)
)
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.