subset

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

subset

yannick misteli-2
Hi,

I have a vector x with certain ID numbers in it and want to create a  
subset from my dataset Y with this vector i.e extract only the data  
with the given IDs from vector x.

example:
x
[1] 10066924 10207314 10257322 10334594 10348247

and now I want to create subset of dataset "assignee" with assignee
$pdpass ==  x

thanks

______________________________________________
[hidden email] 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 | Threaded
Open this post in threaded view
|

Re: subset

K. Elo
Hi Yannick,

yannick misteli wrote:

> I have a vector x with certain ID numbers in it and want to create a
> subset from my dataset Y with this vector i.e extract only the data with
> the given IDs from vector x.
>
> example:
> x
> [1] 10066924 10207314 10257322 10334594 10348247
>
> and now I want to create subset of dataset "assignee" with
> assignee$pdpass ==  x

Try this:

assignee.1<-subset(assignee, pdpass %in% x)

Kind regards,
Kimmo

______________________________________________
[hidden email] 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 | Threaded
Open this post in threaded view
|

Odp: subset

PIKAL Petr
In reply to this post by yannick misteli-2
Hi

[hidden email] napsal dne 05.03.2009 14:00:25:

> Hi,
>
> I have a vector x with certain ID numbers in it and want to create a
> subset from my dataset Y with this vector i.e extract only the data
> with the given IDs from vector x.
>
> example:
> x
> [1] 10066924 10207314 10257322 10334594 10348247
>
> and now I want to create subset of dataset "assignee" with assignee
> $pdpass ==  x

Use %in% operator.

Regards
Petr


>
> thanks
>
> ______________________________________________
> [hidden email] 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.

______________________________________________
[hidden email] 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.