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

bookTransposing

Good! Matrices are widely used in math, starting with different geometrical transformations, and ending with neural networks (yes, matrices are commonly used in AI).

What if we have a matrix and want to 'rotate' it? (or vice versa)?

In math, this operation is called transposing. It swaps columns with rows. In R this operation is implemented under t() function. This function receives the matrix you want to transpose as the parameter. For example,

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

As you can see, the initial matrix was 2x3 (2 rows and 3 columns), and the transposed is 3x2.

Tarefa

Swipe to start coding

Given the matrix from the previous chapter.

  1. Assign this matrix to the m variable.
  2. Output the transposed m matrix.

Solução

Tudo estava claro?

Como podemos melhorá-lo?

Obrigado pelo seu feedback!

Seção 4. Capítulo 3
single

single

Pergunte à IA

expand

Pergunte à IA

ChatGPT

Pergunte o que quiser ou experimente uma das perguntas sugeridas para iniciar nosso bate-papo

Suggested prompts:

Can you explain more about how the t() function works in R?

What are some practical uses of transposing a matrix?

Can you show what the output of the code would look like?

close

Awesome!

Completion rate improved to 2.27

bookTransposing

Deslize para mostrar o menu

Good! Matrices are widely used in math, starting with different geometrical transformations, and ending with neural networks (yes, matrices are commonly used in AI).

What if we have a matrix and want to 'rotate' it? (or vice versa)?

In math, this operation is called transposing. It swaps columns with rows. In R this operation is implemented under t() function. This function receives the matrix you want to transpose as the parameter. For example,

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

As you can see, the initial matrix was 2x3 (2 rows and 3 columns), and the transposed is 3x2.

Tarefa

Swipe to start coding

Given the matrix from the previous chapter.

  1. Assign this matrix to the m variable.
  2. Output the transposed m matrix.

Solução

Switch to desktopMude para o desktop para praticar no mundo realContinue de onde você está usando uma das opções abaixo
Tudo estava claro?

Como podemos melhorá-lo?

Obrigado pelo seu feedback!

close

Awesome!

Completion rate improved to 2.27
Seção 4. Capítulo 3
single

single

some-alt