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

What's The REAL Secret To First Date Success With a Woman? Click Here To Find Out

Teach Your Child To Read

Powerful WordPress hosting for WordPress professionals

Disclosure: My content contains affiliate links.

29,957 questions

39,172 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
# 

 


Protect Your Privacy - Download VPN


answered Jul 7, 2021 by avibootz

Related questions

1 answer 71 views
1 answer 53 views
53 views asked Jul 7, 2021 by avibootz
1 answer 50 views
50 views asked Jul 7, 2021 by avibootz
1 answer 73 views
1 answer 46 views
46 views asked Jul 3, 2021 by avibootz
...