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,709 questions

55,473 answers

573 users

How to create matrix with numbers and NA values in R

1 Answer

0 votes
m = matrix(sample(c(NA, 1:10), 100, replace = TRUE), 10)
 
print(m)
 

 
 
       
       
# run:
#
#       [,1] [,2] [,3] [,4] [,5] [,6] [,7] [,8] [,9] [,10]
#  [1,]    1    5    3   10    8    1    2    7   NA     6
#  [2,]    3    8    8    4    3    6   NA    8    7     9
#  [3,]   10   NA   10    7    2    1    8   NA    6     5
#  [4,]    4   NA    4   10    3   10    8    1    8     3
#  [5,]    7    9    1    8    5    4    9   10    1     2
#  [6,]    2   10    9    7   NA    5    1    6    8     9
#  [7,]   10   10    5   NA    8    7    5    7    4    NA
#  [8,]   10    5    4    7    3   NA   10    7   10     8
#  [9,]    4    5   10    7    7    6    8    6    9     9
# [10,]   10    9    1    3   10   10    8    8   NA     1
#

 



answered Jul 9, 2021 by avibootz

Related questions

1 answer 261 views
1 answer 285 views
1 answer 267 views
1 answer 272 views
2 answers 314 views
1 answer 245 views
1 answer 176 views
176 views asked Jul 6, 2021 by avibootz
...