A combination of subsetting and ?substr should get you close to a solution.
If the middle sequence you referenced isn't always the same distance from
the first character, you may have to involve regular expressions to find
"the middle".

On Wednesday, February 24, 2016, Bert Gunter <bgunter.4...@gmail.com> wrote:

> Have you gone through any R tutorials yet? I didn't entirely
> understand your question (and so cannot answer), but this sounds like
> a basic subsetting/data wrangling task that you should know how to do
> if you have gone through a basic tutorial or two.
>
> See also ?subset, ?"[" (basic indexing) and possibly also the plyR,
> dplyr, or data.table packages that provide what some consider more
> convenient and/or faster interfaces to these sorts of tasks.
>
> See also: http://vita.had.co.nz/papers/tidy-data.pdf
>
> for a nice article on "tidying" data (using plyr/dplyr).
>
>
>
> Cheers,
> Bert
>
>
> Bert Gunter
>
> "The trouble with having an open mind is that people keep coming along
> and sticking things into it."
> -- Opus (aka Berkeley Breathed in his "Bloom County" comic strip )
>
>
> On Wed, Feb 24, 2016 at 6:57 PM, Val <valkr...@gmail.com <javascript:;>>
> wrote:
> > Hi all,
> >
> > One of the the columns of a data frame has a value such like
> >
> > AAAAS-2001-yy
> > AAAAS-2004-xx
> > FFFFF-2007-SS
> > and so on
> >
> > based on this column (variable) I want  subset a data frame  where the
> > middle value of this variable is between 2001 to 2004.
> > THE END RESULT THE DATA FRAME  WILL BE THIS.
> >
> > AAAAS-2001-yy
> > AAAAS-2004-xx
> >
> >
> > THANK YOU IN ADVANCE
> >
> >         [[alternative HTML version deleted]]
> >
> > ______________________________________________
> > R-help@r-project.org <javascript:;> mailing list -- To UNSUBSCRIBE and
> more, see
> > 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@r-project.org <javascript:;> mailing list -- To UNSUBSCRIBE and
> more, see
> 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.
>

        [[alternative HTML version deleted]]

______________________________________________
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
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