[R] Subset using partial values
Henrique Dallazuanna
wwwhsd at gmail.com
Wed Mar 3 15:40:59 CET 2010
Try this:
subset(x, grepl('411', Main_condition))
On Wed, Mar 3, 2010 at 11:33 AM, Newbie19_02 <nvanzuydam at gmail.com> wrote:
>
> Hi everyone,
>
> I would like to subset a data.frame using partial values.
>
> For example I have the following data.frame:
>
> PROCHI Main_condition
> 1234 411
> 1235 4110
> 1236 4111
> 1237 I20
> 1238 I201
> 1239 I202
>
> Now let's say that I use the Subset function. Ordinarily I would use it as
> follows Subset(x, Main_condition=="411"|Main_condition=="4110" etc to get
> all the 411s.
>
> Is there a way that you can subset by only using part of the term that you
> wish to subset by?
>
> Thanks,
> Natalie
> --
> View this message in context: http://n4.nabble.com/Subset-using-partial-values-tp1576614p1576614.html
> Sent from the R help mailing list archive at Nabble.com.
>
> ______________________________________________
> R-help at 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
More information about the R-help
mailing list