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

 

 

Advertisements
This entry was posted in Computing and Others, Econometrics, Statistic and tagged , , , , , , , . Bookmark the permalink.

5 Responses to Julia-R Cheatsheet – Manipulating Vectors and Matrices

  1. Pingback: Julia-R Cheatsheet – Creating Random Numbers | Economic Theory Blog

  2. Pingback: Julia-R Cheatsheet – Creating Matrices | Economic Theory Blog

  3. Pingback: Julia-R Cheatsheet – Creating Vectors | Economic Theory Blog

  4. Pingback: Julia-R Cheatsheet – Accessing Vector/Matrix Elements | Economic Theory Blog

  5. Pingback: Julia-R Cheatsheet – Mathematical Operations | Economic Theory Blog

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 )

Google+ photo

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

Connecting to %s