Added basic colon function

This commit is contained in:
Waldir Leoncio 2020-01-15 15:18:49 +01:00
parent f8f65f176c
commit 1b79529e4b
3 changed files with 33 additions and 0 deletions

12
R/colon.R Normal file
View file

@ -0,0 +1,12 @@
#' @title Vector creation
#' @description Simulates the function `colon()` and its equivalent `:` operator from Matlab, which have a similar but not quite equivalent behavior when compared to `seq()` and `:` in R.
#' @param a initial number
#' @param b final number
#' @export
colon <- function(a, b) {
if (a <= b) {
return(a:b)
} else {
return(vector(mode = "numeric"))
}
}