# Manipulating Vectors and Matrices

How to manipulate vectors and matrices in Julia and R? The following table translates the most common Julia commands into R language.

Julia R
Transpose
```
A.'
```
```
t(A)
```
Complex conjugate transpose
```
A '
```
```
Conj(t(A))
```
Concatenate horizontally
```
A = [[1 2] [1 2]]
```
```
A = c(c(1,2),c(1,2))
```
Concatenate vertically
```
A = [[1 2]; [1 2]]
```
```
A = rbind(c(1,2),c(1,2))
```
Reshape (to 5 rows, 2 columns)
```
A = reshape(1:10, 5, 2)
```
```
A = matrix(1:10,5,2)
```
Convert matrix to vector
```
A[:]
```
```
c(A)
```
Repeat matrix (3 times in the row dimension, 4 times in the column dimension)
```
repmat(A,3,4)
```
```
kronecker(matrix(1,3,4),A)
```
Flip Matrix form left to right
```
flipdim(A, 2)
```
```
A[,dim(A):1]
```
Flip Matrix up/down
```
flipdim(A, 2)
```
```
A[dim(A):1,]
```

## 5 thoughts on “Julia-R Cheatsheet – Manipulating Vectors and Matrices”

This site uses Akismet to reduce spam. Learn how your comment data is processed.