5. Advanced Data Structures
Sometimes data require more complex storage than simple vector
s and thankfully R
provides a host of data structures. The most common are the data.frame
, matrix
and list
, followed by the array
. Of these, the data.frame
will be most familiar to anyone who has used a spreadsheet, the matrix
to people familiar with matrix math and the list
to programmers.
5.1 data.frame
s
Perhaps one of the most useful features of R
is the data.frame
. It is one of the most often cited reasons for R
’s ease of use.
On the surface a data.frame
is just like an Excel spreadsheet in that it has columns and rows. In statistical terms, each column is a variable and each row is an observation.
In terms of how R
organizes data.frame
s, each column ...
Get R for Everyone: Advanced Analytics and Graphics, 2nd Edition now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.