try this:

> x <-  "p-value = 0.0765"
> sig <- as.numeric(sub(".*=(.*)", "\\1", x))
>
> sig
[1] 0.0765
>



On Mon, Aug 5, 2013 at 10:41 AM, Lívio Cipriano <lcmail4li...@gmail.com>wrote:

> Hi,
>
> I'm writing some R scripts and I would like to grab outputs from R
> functions
> to control if tests. Example, one function outputs something like "p-vale =
> 0.0765" and I want to program the following pseudo code in R
>
> sig = grep pvalue
>
> if (sig > 0.05)
>         a()
> else
>         b()
>
> Should I use the grep function of R (
> http://stat.ethz.ch/R-manual/R-devel/library/base/html/grep.html
> ) or is there other easy way to do it?
>
> Regards
>
> Lívio Cipriano
>
> ______________________________________________
> R-help@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.
>



-- 
Jim Holtman
Data Munger Guru

What is the problem that you are trying to solve?
Tell me what you want to do, not how you want to do it.

        [[alternative HTML version deleted]]

______________________________________________
R-help@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.

Reply via email to