On Tue, Feb 08, 2011 at 08:27:38PM +0530, pankaj borah wrote:
> Hi,
> 
> I have two lists
> 
> 1) List1- 30,000 rows and 104 columns
> 
> 2) List2- a list of 14000 selected rownames? from List 1
> 
> Now, I want to extract all the 104 columns of List1? matching with the 14000 
> selected rownames from List2.? 
> 
> Psedocode will be something like this: 
> match rownames(List2) with rownames(List1)
> extract selected matched 104 coloumns from (List1)
> strore in-> List3
> 
> So the resulting List3 will contain 14,000 rows and 104 coloumns. 
> 
> How do I do it in R ?

Hi.

Let me use a small example

  df <- data.frame(a=1:7, b=11:17, row.names=letters[1:7])
  df

    a  b
  a 1 11
  b 2 12
  c 3 13
  d 4 14
  e 5 15
  f 6 16
  g 7 17

Is the following what you are asking for in terms of this small example?

  df[c("b", "c", "g"), ]

    a  b
  b 2 12
  c 3 13
  g 7 17

Petr Savicky.

______________________________________________
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.

Reply via email to