[R] Data.frame Vs Matrix Vs Array: Definitions Please

Matt Curcio matt.curcio.ri at gmail.com
Wed Oct 27 02:37:46 CEST 2010


Hi All,
I am learning R and having a little trouble with the usage and proper
definitions of data.frames vs. matrix vs vectors. I have read many R
tutorials, and looked over ump-teen 'cheat' sheets and have found that
no one has articulated a really good definition of the differences
between 'data.frames', 'matrix', and 'arrays' and even 'factors'.  I
realize that I might have missed someones R tutorial, and actually
would like to receive 'your' most concise or most useful tutorial.
Any help would be appreciated.

My particular favorite explanation and helpful hint is from the
'R-Inferno'.  Don't get me wrong...  I think this pdf is great and
some tables are excellent. Overall it is a very good primer but this
one section leaves me puzzled.  This quote belies the lack of hard and
fast rules for what and when to use 'data.frames', 'matrix', and
'arrays'.  It discusses ways in which to simplify your work.

Here are a few possibilities for simplifying:
• Don’t use a list when an atomic vector will do.
• Don’t use a data frame when a matrix will do.
• Don’t try to use an atomic vector when a list is needed.
• Don’t try to use a matrix when a data frame is needed.

Cheers,
Matt C



More information about the R-help mailing list