Transposing 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)
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:
- Build a matrix from
num
and assign it to them
variable. - Output the transposed
m
matrix.
Solution
Everything was clear?
Thanks for your feedback!
SectionΒ 4. ChapterΒ 3
single
Ask AI
Ask AI
Ask anything or try one of the suggested questions to begin our chat
Awesome!
Completion rate improved to 2.27
Transposing 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)
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:
- Build a matrix from
num
and assign it to them
variable. - Output the transposed
m
matrix.
Solution
Everything was clear?
Thanks for your feedback!
SectionΒ 4. ChapterΒ 3
single