Bytes
rocket

Your Success, Our Mission!

6000+ Careers Transformed.

What is a Matrix?

Last Updated: 20th August, 2026

matrix is a two-dimensional data structure that stores elements of the same data type, arranged in rows and columns.

Creating a Matrix

m <- matrix(1:6, nrow = 2, ncol = 3)

By default, R fills matrices column-wise.

Accessing Matrix Elements

m[12]   # Row 1, Column 2

Matrix Operations

m * 2     # Scalar multiplication

Matrix multiplication:

a <- matrix(1:4, nrow = 2)
b <- matrix(5:8, nrow = 2)
a %*% b

Key Points

  • All elements must be of the same type
  • Commonly used in mathematical and statistical computations
  • Supports linear algebra operations

Lists

What is a List?

list is a flexible data structure that can store different types of data together.

Creating a List

my_list <- list(
  name = "R Programming",
  version = 4.3,
  active = TRUE,
  scores = c(809085)
)

Accessing List Elements

my_list$name
my_list[[2]]

Why Use Lists?

  • Store complex data
  • Store outputs of models
  • Used extensively in advanced R programming

Key Points

  • Elements can be of different data types

  • Can contain vectors, matrices, data frames, and even other lists

  • Very powerful and flexible

     

Data Frames

What is a Data Frame?

data frame is the most commonly used data structure in R for data analysis. It is similar to a table where:

  • Columns can have different data types
  • Each column is a vector
  • Each row represents an observation

Creating a Data Frame

students <- data.frame(
  name = c("A""B""C"),
  age = c(202122),
  score = c(859088)
)

Accessing Data Frame Data

students$name
students[1, ]
students[, 2]

Basic Data Frame Functions

head(students)
str(students)
summary(students)

Why Data Frames are Important

  • Ideal for real-world datasets
  • Used in data analysis, machine learning, and visualization
  • Compatible with most R packages

Comparison of Data Structures

Data Structure

Dimensions

Data Type

Common Use

Vector1DSameBasic data storage
Matrix2DSameMathematical operations
ListAnyDifferentComplex data storage
Data Frame2DDifferentData analysis
Module 4: Core Data Structures in RWhat is a Matrix?

Top Tutorials

Logo
Computer Science

CNN in Deep Learning 2026

A beginner-friendly guide to CNNs: understand deep learning essentials, create Python-based models, and explore advanced applications.

4 Modules12 Lessons189 Learners
Start Learning
Logo
Computer Science

Breaking The Limits: Scaling Databases with MySQL Partitioning

Learn MySQL partitioning with examples. Improve query performance, scalability, and data management using RANGE, LIST, HASH, KEY, and composite techniques.

7 Modules11 Lessons91 Learners
Start Learning
Logo

ML in Action: Hands-On Guide to Deploying and Serving Models

Learn model deployment and serving—from concepts to real-world architectures, tools, APIs, containers, and cloud workflows for production-ready ML.

3 Modules6 Lessons91 Learners
Start Learning
  • Official Address
  • 4th floor, 133/2, Janardhan Towers, Residency Road, Bengaluru, Karnataka, 560025
  • Communication Address
  • Follow Us
  • facebook
    instagram
    linkedin
    twitter
    youtube
    telegram

© 2026 AlmaBetter