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 columns of a matrix in R

1 Answer

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

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

print(columns)
  
  
  
  
# 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]
# [1,]    1   11
# [2,]    2   12
# [3,]    3   13
# [4,]    4   14
# [5,]    5   15
# 

 



answered Jul 6, 2021 by avibootz

Related questions

1 answer 190 views
1 answer 210 views
1 answer 205 views
1 answer 149 views
1 answer 181 views
1 answer 194 views
1 answer 105 views
105 views asked Jul 6, 2021 by avibootz
...