Member-only story

How To Create a Matrix in R programming

Pierre DeBois
5 min readJul 16, 2022

--

Matrices are a part of the data science landscape. They are essential for all types of data models, from simple tables to matrices for a Markov chain. Creating a matrix is pretty easy in R programming. This post covers the basics of matrices in R, and can help enhance your understanding of data models.

The Way R Views Matrices

Matrices are central in R programming, mainly for how the programming is designed to store each value of a matrix element.

R programming provides a convenient computing environment for matrices because of how R treats vectors. R considers vectors as its basic data object. It evaluates the objects as an interpreted language — directly executing what it sees in the objects. R stores vector elements in a column-wise arrangement. This means as it stores each value of a vector element, it arranges each one consecutively in columns. This is called column-major order (This Wikipedia page explains the details, as well as a row-major order). The major order principle is meant to organize the elements for memory access. R treats all objects in a column-major order. Scalars and matrices are variations of a vector object. In a programming script, matrices are a series of vectors tied together.

Because of this programming structure, data analysts and developers plan R…

--

--

Pierre DeBois
Pierre DeBois

Written by Pierre DeBois

#analytics |#datascience |#JS |#rstats |#marketing services for #smallbiz | #retail | #nonprofits Contrib @CMSWire @smallbiztrends #blackbusiness #BLM

No responses yet