Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
Learn Transposing Matrices | Matrices
R Introduction

bookTransposing Matrices

Transposition is the operation of swapping the rows and columns of a matrix. In R, this is done with the t() function.

Example

123456
# Initial matrix m <- matrix(1:6, nrow = 2) m # Transposed matrix t(m)
copy

The original matrix has 2 rows and 3 columns. After transposition, it becomes 3 rows and 2 columns.

Task

Swipe to start coding

You have a vector num. Your goal is to:

  1. Build a matrix from num and assign it to the m variable.
  2. Output the transposed m matrix.

Solution

Everything was clear?

How can we improve it?

Thanks for your feedback!

SectionΒ 4. ChapterΒ 3
single

single

Ask AI

expand

Ask AI

ChatGPT

Ask anything or try one of the suggested questions to begin our chat

Suggested prompts:

Can you explain how the `t()` function works in more detail?

What happens if I transpose a square matrix?

Can you show another example with a different matrix size?

close

Awesome!

Completion rate improved to 2.27

bookTransposing Matrices

Swipe to show menu

Transposition is the operation of swapping the rows and columns of a matrix. In R, this is done with the t() function.

Example

123456
# Initial matrix m <- matrix(1:6, nrow = 2) m # Transposed matrix t(m)
copy

The original matrix has 2 rows and 3 columns. After transposition, it becomes 3 rows and 2 columns.

Task

Swipe to start coding

You have a vector num. Your goal is to:

  1. Build a matrix from num and assign it to the m variable.
  2. Output the transposed m matrix.

Solution

Switch to desktopSwitch to desktop for real-world practiceContinue from where you are using one of the options below
Everything was clear?

How can we improve it?

Thanks for your feedback!

SectionΒ 4. ChapterΒ 3
single

single

some-alt