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

51,771 answers

573 users

How to get multiple rows of a matrix in R

1 Answer

0 votes
m <- matrix(1:25, nrow=5)
 
print(m)

rows <- m[c(1,3), ]

print(rows)
  
  
  
  
# run:
#
#      [,1] [,2] [,3] [,4] [,5]
# [1,]    1    6   11   16   21
# [2,]    2    7   12   17   22
# [3,]    3    8   13   18   23
# [4,]    4    9   14   19   24
# [5,]    5   10   15   20   25
#      [,1] [,2] [,3] [,4] [,5]
# [1,]    1    6   11   16   21
# [2,]    3    8   13   18   23
# 
#

 



answered Jul 6, 2021 by avibootz

Related questions

1 answer 181 views
1 answer 198 views
198 views asked Jul 8, 2021 by avibootz
1 answer 149 views
1 answer 228 views
1 answer 120 views
1 answer 184 views
1 answer 232 views
...