Message-ID: <8760t8jhjl.fsf@enricoschumann.net>
Date: 2016-06-17T09:22:54Z
From: Enrico Schumann
Subject: filter a data.frame in dependence of a column value
In-Reply-To: <HE1PR07MB1212A945302ECCD0C285349090570@HE1PR07MB1212.eurprd07.prod.outlook.com> (Matthias Weber's message of "Fri, 17 Jun 2016 07:49:42 +0000")
On Fri, 17 Jun 2016, Matthias Weber <Matthias.Weber at fntsoftware.com> writes:
> Hello togehter,
>
> i have short question, maybe anyone can help me.
>
> I have a data.frame like this one:
>
> NO ORDER
> 1 1530 for Mr. Muller (10.0 -> 11.2)
> 2 1799 for Mr Giulani
> 3 1888 for Mr. Marius (11.2 -> 12)
>
> I need a solution, which only contains the values in brackets. The result should look like the following:
>
> NO ORDER
> 1 1530 for Mr. Muller (10.0 -> 11.2)
> 2 1888 for Mr. Marius (11.2 -> 12)
>
> I tried it with the following code, but that doesn't work.
>
> data4.1<-data3[data3$ORDER%in% "[(]*->*[)]",]
>
> maybe anyone can help me.
>
> Thank you.
>
> Best regards
>
> Mat
>
Try ?grepl instead of %in%.
x <- c("for Mr. Muller (10.0 -> 11.2)",
"for Mr Giulani",
"for Mr. Marius (11.2 -> 12)")
grepl("[(].*->.*[)]", x)
--
Enrico Schumann
Lucerne, Switzerland
http://enricoschumann.net