[R] Extraction of columns from two matrices

2011-05-05 Thread nisha chandran
Hi,

I have two matrices with 4885 cols and 36 cols respectively . I would like
to extract these 36 columns from the bigger matrix, the column values are
different but the column names would be the same.Hence based on the names I
would like to perform my operation. So is there any way of extracting this
info in an easy way. I have tried names,which,grep,subset none have worked.
Could someone help me out here



Thanks a ton
Nisha

[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] Extraction of columns from two matrices

2011-05-05 Thread Dennis Murphy
Hi:

Is this what you have in mind?

m1 - matrix(rpois(100, 10), nrow = 10, dimnames = list(NULL,
paste('V', 1:10, sep = '')))
m2 - matrix(rpois(40, 10), nrow = 10, dimnames = list(NULL,
paste('V', c(2, 5, 7, 10), sep = '')))
colnames(m1)
colnames(m2)

m1[, colnames(m2)]

HTH,
Dennis

On Wed, May 4, 2011 at 11:10 PM, nisha chandran
slamdunkangel...@gmail.com wrote:
 Hi,

 I have two matrices with 4885 cols and 36 cols respectively . I would like
 to extract these 36 columns from the bigger matrix, the column values are
 different but the column names would be the same.Hence based on the names I
 would like to perform my operation. So is there any way of extracting this
 info in an easy way. I have tried names,which,grep,subset none have worked.
 Could someone help me out here



 Thanks a ton
 Nisha

        [[alternative HTML version deleted]]

 __
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
 and provide commented, minimal, self-contained, reproducible code.


__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] Extraction of columns from two matrices

2011-05-05 Thread nisha chandran
Yea it did...
Thanks :)

On Thu, May 5, 2011 at 3:07 PM, Dennis Murphy djmu...@gmail.com wrote:

 Hi:

 Is this what you have in mind?

 m1 - matrix(rpois(100, 10), nrow = 10, dimnames = list(NULL,
 paste('V', 1:10, sep = '')))
 m2 - matrix(rpois(40, 10), nrow = 10, dimnames = list(NULL,
 paste('V', c(2, 5, 7, 10), sep = '')))
 colnames(m1)
 colnames(m2)

 m1[, colnames(m2)]

 HTH,
 Dennis

 On Wed, May 4, 2011 at 11:10 PM, nisha chandran
 slamdunkangel...@gmail.com wrote:
  Hi,
 
  I have two matrices with 4885 cols and 36 cols respectively . I would
 like
  to extract these 36 columns from the bigger matrix, the column values are
  different but the column names would be the same.Hence based on the names
 I
  would like to perform my operation. So is there any way of extracting
 this
  info in an easy way. I have tried names,which,grep,subset none have
 worked.
  Could someone help me out here
 
 
 
  Thanks a ton
  Nisha
 
 [[alternative HTML version deleted]]
 
  __
  R-help@r-project.org mailing list
  https://stat.ethz.ch/mailman/listinfo/r-help
  PLEASE do read the posting guide
 http://www.R-project.org/posting-guide.html
  and provide commented, minimal, self-contained, reproducible code.
 


[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.