Language Reference

J Function

creates a matrix of identical values

J( nrow<, ncol<, value>)

The inputs to the J function are as follows:
nrow
is a numeric matrix or literal giving the number of rows.

ncol
is a numeric matrix or literal giving the number of columns.

value
is a numeric or character matrix or literal for filling the rows and columns of the matrix.
The J function creates a matrix with nrow rows and ncol columns with all elements equal to value. If ncol is not specified, it defaults to nrow. If value is not specified, it defaults to 1. The REPEAT and SHAPE functions can also perform this operation, and they are more general.

Examples of the J function are as follows:

  
    b=j(3); 
  
                 B             3 rows      3 cols    (numeric) 
  
                                 1         1         1 
                                 1         1         1 
                                 1         1         1 
  
  
    r=j(5,2,'xyz'); 
  
            R          5 rows      2 cols    (character, size 3) 
  
                                 xyz xyz 
                                 xyz xyz 
                                 xyz xyz 
                                 xyz xyz 
                                 xyz xyz
 

Previous Page | Next Page | Top of Page