Skip to content
Prev 303544 / 398503 Next

r data structures

On Aug 16, 2012, at 1:50 PM, Schumacher, Jay S wrote:

            
You can have as many personal representations of R structures as  
you want. If you are intent on communication with other useRs, I think  
you should restrict the use of "dimension" to objects that return a  
non-NULL value from dim(). And I think one should use 'length' for the  
dimension-like aspect for atomic vectors and lists. (I originally used  
the word "attribute", but that is a specific function and applied to  
such structures would not return a "length"-value.) Dimensions is R  
can have other attributes such as names that often need to be accessed  
or manipulated

    One further source of confusion is length() applied to matrices or  
dataframes. It will return a value from matrices that is nrow()*ncol()  
and from dataframes (which are really lists under the hood) a value  
that is ncol(). The latter value is rather different than my naive  
expectation, which was that a dataframe's "length" would be the number  
of cases or rows.

    That webpage obviously has its own definition of dimension (and  
it's perfectly free to make up its own terms) but it is not one that  
is in accord with "An Introduction to R" or with typical R discourse.