[R] subset a matrix

2006-04-12 Thread zhijie zhang
Dear friends,
 I have a (20*30) matrix,and want to get a subset of it like the following:
The original matrix: rows:1,2,3,20; columns:1,2,3,30
I want to get my subset of The original matrix and delete others:
   rows:1,3,5,7,...19;   columns:1,3,5.29


--
Kind Regards,Zhi Jie,Zhang ,PHDDepartment of EpidemiologySchool of Public
HealthFudan UniversityTel:86-21-54237149

[[alternative HTML version deleted]]

__
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html


Re: [R] subset a matrix

2006-04-12 Thread Peter Ehlers
Assuming that you want odd-numbered rows/cols, the
seq() function is handy, as in:

mat - matrix(1:(20*30), nr = 20)
mat1 - mat[seq(1, 19, by = 2), seq(1, 29, by = 2)]

Peter Ehlers

zhijie zhang wrote:

 Dear friends,
  I have a (20*30) matrix,and want to get a subset of it like the following:
 The original matrix: rows:1,2,3,20; columns:1,2,3,30
 I want to get my subset of The original matrix and delete others:
rows:1,3,5,7,...19;   columns:1,3,5.29
 
 
 --
 Kind Regards,Zhi Jie,Zhang ,PHDDepartment of EpidemiologySchool of Public
 HealthFudan UniversityTel:86-21-54237149
 
   [[alternative HTML version deleted]]
 
 __
 R-help@stat.math.ethz.ch mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html

__
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html


Re: [R] subset a matrix

2006-04-12 Thread ronggui
 x=matrix(rnorm(20*30),20)
 y=x[seq(1,20,by=2),seq(1,30,by=2)]



2006/4/12, zhijie zhang [EMAIL PROTECTED]:
 Dear friends,
  I have a (20*30) matrix,and want to get a subset of it like the following:
 The original matrix: rows:1,2,3,20; columns:1,2,3,30
 I want to get my subset of The original matrix and delete others:
rows:1,3,5,7,...19;   columns:1,3,5.29


 --
 Kind Regards,Zhi Jie,Zhang ,PHDDepartment of EpidemiologySchool of Public
 HealthFudan UniversityTel:86-21-54237149

 [[alternative HTML version deleted]]

 __
 R-help@stat.math.ethz.ch mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html



--
黄荣贵
Deparment of Sociology
Fudan University

__
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html