Welcome to collectivesolver - Programming & Software Q&A with code examples. A website with trusted programming answers. All programs are tested and work.

Contact: aviboots(AT)netvision.net.il

Instant Grammar Checker - Correct all grammar errors and enhance your writing

Semrush - keyword research tool

Prodentim Probiotics Specially Designed For The Health Of Your Teeth And Gums

Teach Your Child To Read

Disclosure: My content contains affiliate links.

31,615 questions

41,668 answers

573 users

How to divide elements of two matrices in R

1 Answer

0 votes
vec <- c(1, 2, 3, 1, 0, 2, 3, 1, 1)
m1 <- matrix(vec, nrow = 3, ncol = 3)
   
vec <- c(2, 1, 3, 0, 0, 1, 2, 1, 0)
m2 <- matrix(vec, nrow = 3, ncol = 3)
  
divide <- m1 / m2
    
print(m1)
print(m2)
print(divide)
   
   
   
     
     
# run:
#
#      [,1] [,2] [,3]
# [1,]    1    1    3
# [2,]    2    0    1
# [3,]    3    2    1
#      [,1] [,2] [,3]
# [1,]    2    0    2
# [2,]    1    0    1
# [3,]    3    1    0
#      [,1] [,2] [,3]
# [1,]  0.5  Inf  1.5
# [2,]  2.0  NaN  1.0
# [3,]  1.0    2  Inf
# 

 



Learn & Practice Python
with the most comprehensive set of 13 hands-on online Python courses
Start now


answered Jul 7, 2021 by avibootz

Related questions

1 answer 99 views
1 answer 83 views
83 views asked Jul 7, 2021 by avibootz
1 answer 76 views
76 views asked Jul 7, 2021 by avibootz
1 answer 89 views
1 answer 64 views
64 views asked Jul 3, 2021 by avibootz
...