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

Buy a domain name - Register cheap domain names from $0.99 - Namecheap

Scalable Hosting That Grows With You

Secure & Reliable Web Hosting, Free Domain, Free SSL, 1-Click WordPress Install, Expert 24/7 Support

Semrush - keyword research tool

Boost your online presence with premium web hosting and servers

Disclosure: My content contains affiliate links.

39,851 questions

51,772 answers

573 users

How to generate a 10x10 matrix of 5 random numbers from 0 to 30 in R

1 Answer

0 votes
m = matrix(sample(c(0:30), 100, replace = TRUE), 10)
 
print(m)
  
 
  
        
        
# run:
#
#       [,1] [,2] [,3] [,4] [,5] [,6] [,7] [,8] [,9] [,10]
#  [1,]    7   10   27    5   29   21   24   11   10    20
#  [2,]   16    0   12   13    8   19    2   20    1     4
#  [3,]    9   23    8   23   14   10    1   27   20    10
#  [4,]    4   28   22   14    2   21    7   25    9     6
#  [5,]   27   12    6    0   22   12    3   26   25     7
#  [6,]   21   22    3   18   23   15   19   11    3     4
#  [7,]   23    9   18   15    9   17   26   23   16     5
#  [8,]   28    7   14   20   30   21    7   28    4     7
#  [9,]   10   18   13    3    9    6   26   12    0    22
# [10,]    4   12    7   10    9   23   27   23   28    25
#

 



answered Jul 10, 2021 by avibootz

Related questions

2 answers 233 views
1 answer 189 views
1 answer 213 views
2 answers 266 views
1 answer 247 views
1 answer 241 views
...