Try this:

 subset(xx, id %in% temp)

On Thu, May 13, 2010 at 10:48 AM, Carrie Li <carrieands...@gmail.com> wrote:

> Hi, dear R-helpers,
>
> I have a simple question regarding selecting subset of a variable based on
> another variable.
> Here is the example:
>
> xx=rnorm(10)
> id=sample(1:10, 10)
>
> temp=c(6, 1, 8, 2)
>
> Now, all I want is xx's that their id are 6, 1, 8, 2, instead of the
> position.
>
> Any suggestions ?
>
> Thank you all your help !!
>
> Carrie
>
>        [[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.
>



-- 
Henrique Dallazuanna
Curitiba-Paraná-Brasil
25° 25' 40" S 49° 16' 22" O

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

Reply via email to