[R] r data structures

Schumacher, Jay S jays at neo.tamu.edu
Thu Aug 16 22:50:55 CEST 2012


are these correct/accurate/sensible statements:

  a vector is a one dimensional object.
  a matrix is a two dimensional object.

  a list is a one dimensional object.

i'm working from this web page:    http://www.agr.kuleuven.ac.be/vakken/statisticsbyR/someDataStructures.htm



-----------------------------------------------------------------


On Aug 16, 2012, at 11:49 AM, Schumacher, Jay S wrote:

>
>
> hi,
>  i'm trying to understand r data structures.  i see that vectors,  
> matrix, factors and arrays have a "dimension."
>  there seems to be no mention of dimensionality anywhere for lists  
> or dataframes.  can i consider lists and frames to be of fixed  
> dimension 2?

About half of what you have deduced is wrong. Matrices, arrays, and  
dataframes do have dimensions, at least in technical R parlance,  
namely they have an attribute which can be queried with dim(). By  
definition matrices and dataframes have 2 dimensions. Arrays and  
matrices can be redimensioned, but dataframes cannot.

Factors, lists, and atomic vectors do not have "dimensions", but they  
do have "lengths". An appropriately structured list (one with vectors  
all the same length) can be coerced to a dataframe with as.data.frame().

-- 

David Winsemius, MD
Alameda, CA, USA



More information about the R-help mailing list