Added basic colon function
This commit is contained in:
parent
f8f65f176c
commit
1b79529e4b
3 changed files with 33 additions and 0 deletions
12
R/colon.R
Normal file
12
R/colon.R
Normal 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"))
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue