Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

How to recycle an [x, y] vector while adding a 2 x z matrix?

How can I do this without the first replicate using recycling or matrix multiplication?

replicate(5, c(-74.04456199608506, 40.68923184725649)) + replicate(5, rnorm(2))

>Solution :

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

You could just use +, therefore using recycling:

replicate(5, rnorm(2)) + c(-74.04456199608506, 40.68923184725649)

output

          [,1]      [,2]      [,3]      [,4]      [,5]
[1,] -74.30676 -75.55923 -74.57547 -73.35665 -75.33159
[2,]  39.11709  39.08770  39.22748  42.78934  41.47697
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading