length_octave: Length of R objects (GNU Octave/MATLAB compatible)

length_octaveR Documentation

Length of R objects (GNU Octave/MATLAB compatible)

Description

Obtain the length of R objects [arrays, matrices, and vectors (including lists)] in a manner compatible with GNU Octave/MATLAB. Some documentation from length.

Usage

length_octave(x)

Arguments

x

An R object (array, matrix, vector)

Value

Return the length of the object x as an integer. "The length is 0 for empty objects, 1 for scalars (in R, a vector of length 1), and the number of elements (in R, the length) for vectors. For matrix objects, the length is the number of rows or columns, whichever is greater (this odd definition is used for compatibility with MATLAB)." Source: Eaton.

Author(s)

Irucka Embry, Samit Basu (FreeMat)

References

  1. Samit Basu (2002-2006). FreeMat v4.0, https://freemat.sourceforge.net/help/inspection_length.html.

  2. John W. Eaton, David Bateman, Søren Hauberg, and Rik Wehbring (November 2022). GNU Octave: A high-level interactive language for numerical computations: Edition 7 for Octave version 7.3.0. https://docs.octave.org/octave.pdf. Page 47.

See Also

length, lengths, size, size

Examples


library(iemisc)

import::from(matlab, ones)

# Example from pracma isempty

object1 <- matrix(0, 1, 0)

length_octave(object1)




iemisc documentation built on Sept. 25, 2023, 5:09 p.m.