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

Semrush - keyword research tool

Turn ChatGPT, Claude, Gemini, And CoPilot Into Your Personal Assistant, Business Coach, Content Creator, And More

AFFILIATE MARKETING Your all-in-one performance engine Manage affiliates, creators, and customer referrals in one unified platform—turning every partnership into measurable growth
Secure & Reliable Web Hosting, Free Domain, Free SSL, 1-Click WordPress Install, Expert 24/7 Support

Boost your online presence with premium web hosting and servers

Disclosure: My content contains affiliate links.

42,685 questions

55,440 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 289 views
1 answer 241 views
1 answer 260 views
2 answers 314 views
1 answer 302 views
1 answer 285 views
...