Re: [R] filter a data.frame in dependence of a column value

2016-06-17 Thread Enrico Schumann
On Fri, 17 Jun 2016, Matthias Weber  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

__
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.


Re: [R] filter a data.frame in dependence of a column value

2016-06-17 Thread Thierry Onkelinx
Dear Mat,

You can use grepl() to select based on are regular expression.

subset(data3, grepl("\\(.*\\)", ORDER))

Best regards,

ir. Thierry Onkelinx
Instituut voor natuur- en bosonderzoek / Research Institute for Nature and
Forest
team Biometrie & Kwaliteitszorg / team Biometrics & Quality Assurance
Kliniekstraat 25
1070 Anderlecht
Belgium

To call in the statistician after the experiment is done may be no more
than asking him to perform a post-mortem examination: he may be able to say
what the experiment died of. ~ Sir Ronald Aylmer Fisher
The plural of anecdote is not data. ~ Roger Brinner
The combination of some data and an aching desire for an answer does not
ensure that a reasonable answer can be extracted from a given body of data.
~ John Tukey

2016-06-17 9:49 GMT+02:00 Matthias Weber :

> 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
>
> [[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.
>

[[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.


[R] filter a data.frame in dependence of a column value

2016-06-17 Thread Matthias Weber
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

[[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.