[go: up one dir, main page]

Menu

[3bfb4b]: / source / R / ones.R  Maximize  Restore  History

Download this file

20 lines (18 with data), 573 Bytes

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
#' Creates a matrix of ones
#'
#' Function creates a matrix of ones of size (dim1 x dim2). Written to match MATLAB's \code{ones} function.
#'
#'
#' @param dim1 The dimension of the matrix (if square) or the number of rows.
#' @param dim2 The number of columns
#' @return A matrix of ones
#' @family MATLAB
#' @example tests/testthat/examples_fcn_doc/examples_ones.R
#' @export
## Function written to match MATLAB function
## Author: Andrew Hooker
ones <- function(dim1,dim2=NULL){
if(is.null(dim2)) dim2 <- dim1
mat <- matrix(1,dim1,dim2)
return(mat)
}