[R] sustring in dependence of values

Bert Gunter bgunter.4567 at gmail.com
Fri Jun 3 20:30:34 CEST 2016


Use regular expressions:

?grep
?regexp

(The answer is simple, but I think it is worthwhile to learn about
this on your own. Others may disagree and supply you the exact
answer).

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 Fri, Jun 3, 2016 at 7:49 AM, Matthias Weber
<Matthias.Weber at fntsoftware.com> wrote:
> Hello togehter,
>
> maybe anyone can help me with a little problem.
>
> I have the following column in an data.frame (called TEST)
>
>       VERSION
> 1    abc (9.2 -> 10.0)
> 2    def (10.2 -> 11.0)
> 3    ghi (7.4 -> 8.4)
> 4    jkl (10.2 -> 10.4)
> 5    mno (8.1 -> 9.0)
>
> I now need the code for the following result (I want the numbers "before/after" in a separate column. The solution look like this one:
>
>       VERSION              FROM         TO
> 1    abc (9.2 -> 10.0)     9.2             10.0
> 2    def (10.2 -> 11.0)    10.2           11.0
> 3    ghi (7.4 -> 8.4)        7.4             8.4
> 4    jkl (10.2 -> 10.4)      10.2           10.4
> 5    mno (8.1 -> 9.0)      8.1             9.0
>
> Maybe anyone can help me. The substring-code doesn't help me at the moment.
>
> Best regards.
>
> Mat
>
>
>         [[alternative HTML version deleted]]
>
> ______________________________________________
> R-help at 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.



More information about the R-help mailing list