Last active
July 13, 2021 12:34
-
-
Save chrimaho/3f7735f77f9f11987c23ddb702d3b089 to your computer and use it in GitHub Desktop.
R Snippet Extended. Part of: www.github.com/chrimaho/code-snippets
This file contains 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
snippet func | |
${1:FunctionName} <- function(${2:Input1Name}=${3:Input1Default}, ${4:Input2Name}=${5:Input2Default}) { | |
#' @title ${6:Add function title} | |
#' @description ${7:Add function description}. | |
#' @note ${8:Add a note for the developer}. | |
#' @param ${2:Input1Name} `${9:Input1Type}`. ${10:What is Input1?}. Default value `${3:Input1Default}`. | |
#' @param ${4:Input2Name} `${11:Input2Type}`. ${12:What is input2?}. Default value `${5:Input2Default}`. | |
#' @return ${13:What is being returned?}. | |
#' @seealso | |
#' @author chrimaho | |
#' @examples | |
#' # Works | |
#' ${1:FunctionName}( | |
#' ${2:Input1Name}=${3:Input1Default}, | |
#' ${4:Input2Name}=${5:Input2Default} | |
#' ) | |
#' | |
#' # Fails | |
#' ${1:FunctionName}( | |
#' ${2:Input1Name}=${3:Input1Default}, | |
#' ${4:Input2Name}=${5:Input2Default} | |
#' ) | |
# Packages | |
require(assertthat) | |
require(dplyr) | |
# Validations | |
assert_that(${2:Input1Name} %>% is.${9:Input1Type}, msg="'${2:Input1Name}' must be type '${9:Input1Type}'.") | |
assert_that(${4:Input2Name} %>% is.${11:Input2Type}, msg="'${4:Input2Name}' must be type '${11:Input2Type}'.") | |
# Do work | |
#${14:Do work} | |
# Return | |
return(NULL) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment