Is there a built-in convenience function that returns the number of elements in a data.frame, matrix, or vector? length( matrix ) and length( vector ) work, but length( data.frame ) returns the number of columns. prod( dim( vector ) ) returns 1 always, but works fine with matrix/data.frame. I’m looking for a single function that works for all three.
Is there a built-in convenience function that returns the number of elements in a
Share
I don’t think one already exists, so just write your own. You should only need 2 cases, 1) lists, 2) arrays: