Translated basic Matlab function blanks()
This commit is contained in:
parent
5fdff9fee2
commit
32e5020d62
4 changed files with 46 additions and 0 deletions
|
|
@ -2,6 +2,7 @@
|
||||||
|
|
||||||
export(addAlleles)
|
export(addAlleles)
|
||||||
export(admix1)
|
export(admix1)
|
||||||
|
export(blanks)
|
||||||
export(calculatePopLogml)
|
export(calculatePopLogml)
|
||||||
export(colon)
|
export(colon)
|
||||||
export(computeAllFreqs2)
|
export(computeAllFreqs2)
|
||||||
|
|
|
||||||
14
R/blanks.R
Normal file
14
R/blanks.R
Normal file
|
|
@ -0,0 +1,14 @@
|
||||||
|
#' @title Blanks
|
||||||
|
#' @description Create character vector of blanks
|
||||||
|
#' @details This function emulates the behavior of a homonimous function from Matlab
|
||||||
|
#' @param n length of vector
|
||||||
|
#' @return Vector of n blanks
|
||||||
|
#' @author Waldir Leoncio
|
||||||
|
#' @export
|
||||||
|
blanks <- function(n) {
|
||||||
|
if (n < 0) {
|
||||||
|
warning("Negative n passed. Treating as n = 0")
|
||||||
|
n <- 0
|
||||||
|
}
|
||||||
|
paste(rep(" ", n), collapse="")
|
||||||
|
}
|
||||||
23
man/blanks.Rd
Normal file
23
man/blanks.Rd
Normal file
|
|
@ -0,0 +1,23 @@
|
||||||
|
% Generated by roxygen2: do not edit by hand
|
||||||
|
% Please edit documentation in R/blanks.R
|
||||||
|
\name{blanks}
|
||||||
|
\alias{blanks}
|
||||||
|
\title{Blanks}
|
||||||
|
\usage{
|
||||||
|
blanks(n)
|
||||||
|
}
|
||||||
|
\arguments{
|
||||||
|
\item{n}{length of vector}
|
||||||
|
}
|
||||||
|
\value{
|
||||||
|
Vector of n blanks
|
||||||
|
}
|
||||||
|
\description{
|
||||||
|
Create character vector of blanks
|
||||||
|
}
|
||||||
|
\details{
|
||||||
|
This function emulates the behavior of a homonimous function from Matlab
|
||||||
|
}
|
||||||
|
\author{
|
||||||
|
Waldir Leoncio
|
||||||
|
}
|
||||||
|
|
@ -169,3 +169,11 @@ test_that("cell works as expected", {
|
||||||
expect_equal(cell(3, 4), array(dim = c(3, 4)))
|
expect_equal(cell(3, 4), array(dim = c(3, 4)))
|
||||||
expect_equal(cell(5, 7, 6), array(dim = c(5, 7, 6)))
|
expect_equal(cell(5, 7, 6), array(dim = c(5, 7, 6)))
|
||||||
})
|
})
|
||||||
|
|
||||||
|
test_that("blanks works as expected", {
|
||||||
|
expect_warning(blanks(-1))
|
||||||
|
expect_equal(suppressWarnings(blanks(-1)), "")
|
||||||
|
expect_equal(blanks(0), "")
|
||||||
|
expect_equal(blanks(1), " ")
|
||||||
|
expect_equal(blanks(10), " ")
|
||||||
|
})
|
||||||
Loading…
Add table
Reference in a new issue