[R] Subset
Mark Wardle
mark at wardle.org
Fri Mar 23 18:00:23 CET 2007
Sergio Della Franca wrote:
> Dear R-Helpers,
>
> I have this dataset:
>
> YEAR PRODUCTS cluster
> 1 10 2
> 2 42 3
> 3 25 2
> 4 42 3
> 5 40 3
> 6 45 1
> 7 44 1
> 8 47 1
> 9 42 1
>
>
> I want to create a subset (when cluster=1),
>
> YEAR PRODUCTS cluster
> 6 45 1
> 7 44 1
> 8 47 1
> 9 42 1
>
>
> How can i perform this?
>
>
You've answered your own question!
?subset
e.g., subset(my.data, cluster==1)
You should also notice that many R functions support a subset=
parameter, which is very useful!
Mark
--
Dr. Mark Wardle
Specialist registrar, Neurology
Cardiff, UK
More information about the R-help
mailing list