Category Archives: R Data Objects

R Matrices

R matrices are two-dimensional vectors. A matrix starts with a vector and then adds dimension or dim information (e.g. rows and columns), which is stored in a memory slot for the matrix class.  The optional slot, .dimnames, holds row and column names (and their analogues for higher dimension arrays).

Initializing R Matrices

Initializing a matrix is similar to vector creation:

A unit matrix is easy to specify with the diag() function:

Posted in R Data Objects | Comments Off on R Matrices

R Data Import


Quantitative analysis depends on the ability to load and manage many different types of data and file formats.  There are many R data import functions. Some functions ship with base R and others can be found in R packages.

Data Available in R

R is pre-installed with many data sets in the datasets package, which is included in the base distribution of R. R datasets are automatically loaded when the application is started.  A list of all data sets in the package is obtained using the following command:

Posted in R Basics, R Data Import, R Data Objects | Comments Off on R Data Import

R Data Objects

Chapter Outline
Understanding R data objects is core to R programming.  The following sections provide practical insight into use of R data objects by type.

Vectors:            1 dimensional row and column vectors
Matrices:          2 dimensional rectangular data
Arrays:              N-dimensional data
Lists:                 Mixed mode data by component
Factors:            Qualitative data objects
Data Frames:   Mixed mode data by column

Posted in R Data Objects | Comments Off on R Data Objects