On Aug 16, 2012, at 1:50 PM, 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
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.
--
David.
-----------------------------------------------------------------
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
David Winsemius, MD
Alameda, CA, USA
______________________________________________
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.