Julia-R Cheatsheet – Manipulating Vectors and Matrices

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)[2]:1]
Flip Matrix up/down
 
flipdim(A, 2)
 
A[dim(A)[1]:1,]

Complete Julia-R Cheatsheet
1) Creating Vectors
2) Creating Matrices
3) Creating Random Numbers
4) Manipulating Vectors and Matrices
5) Accessing Vector/Matrix Elements

 

 

Advertisement

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

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

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