[R] r data structures

Patrick Burns pburns at pburns.seanet.com
Fri Aug 17 09:38:49 CEST 2012


To slightly correct what's been said: In general
lists are linear objects, but a list can have
dimension.

An example is in Circle 8.1.8 of 'The R Inferno'.

http://www.burns-stat.com/pages/Tutor/R_inferno.pdf

Pat


On 16/08/2012 21:50, Schumacher, Jay S wrote:
>
> 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().
>

-- 
Patrick Burns
pburns at pburns.seanet.com
twitter: @portfolioprobe
http://www.portfolioprobe.com/blog
http://www.burns-stat.com
(home of 'Some hints for the R beginner'
and 'The R Inferno')



More information about the R-help mailing list