Re: [R] subset

From: Martin Becker <martin.becker_at_mx.uni-saarland.de>
Date: Fri, 04 May 2007 09:29:41 +0200

elyakhlifi mustapha wrote:
> hello,
>
>
>> subset(swiss, Agriculture > 60 & Examination != c(14,16), select = c(Agriculture,Examination,Catholic))
>>

Try %in% :

subset(swiss, Agriculture > 60 & Examination %in% c(14,16), select = c(Agriculture,Examination,Catholic))

        Agriculture Examination Catholic
Broye          70.2          16    92.85
Glane          67.8          14    97.16
Veveyse        64.5          14    98.61
Aubonne        67.5          14     2.27
Rolle          60.8          16     7.72

Regards,

  Martin

> Agriculture Examination Catholic
> Broye 70.2 16 3.30
> Glane 67.8 14 4.20
> Aigle 62.0 21 5.16
> Avenches 60.7 19 5.23
> Cossonay 69.3 22 5.62
> Echallens 72.6 18 6.10
> Lavaux 73.0 19 9.96
> Oron 71.2 12 16.92
> Paysd'enhaut 63.5 6 24.20
> Conthey 85.9 3 58.33
> Entremont 84.9 7 84.84
> Herens 89.7 5 90.57
> Martigwy 78.2 12 91.38
> Monthey 64.9 7 92.85
> St Maurice 75.9 9 93.40
> Sierre 84.6 3 96.83
> Sion 63.1 13 97.16
> Warning message:
> la longueur de l'objet le plus long
> n'est pas un multiple de la longueur de l'objet le plus court in: Examination != c(14, 16)
>
> As this example shows I'd like to know if it's possible to drop several lines for example here to drop severals lines from Examination
> thanks
>
>
>
> ___________________________________________________________________________
>
>
>
>
>
> [[alternative HTML version deleted]]
>
> ______________________________________________
> R-help_at_stat.math.ethz.ch 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_at_stat.math.ethz.ch 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. Received on Fri 04 May 2007 - 07:34:41 GMT

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Fri 04 May 2007 - 08:31:43 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.