> x <- readLines(textConnection("Testing marker:
s_1
+ ---------------------------------------------
+
+ Allele   df(0) -LnLk(0)   df(T) -LnLk(T)   ChiSq       p
+     3 7995 29320.30 7994 29311.85 16.90 4e-05 (2229/8000 probands)
+
+ Testing marker:                           s_2
+ ---------------------------------------------
+
+ Allele   df(0) -LnLk(0)   df(T) -LnLk(T)   ChiSq       p
+     3 7995 29339.25 7994 29338.31 1.88 0.1702 ( 121/8000 probands)
+
+ Testing marker:                           s_3
+ ---------------------------------------------
+
+ Allele   df(0) -LnLk(0)   df(T) -LnLk(T)   ChiSq       p
+     3 7995 29340.83 7994 29338.97 3.71 0.0540 (2429/8000 probands)"))
> closeAllConnections()
>
> # find the markers
> markers <- grep("^Testing marker", x)
> # get the marker number
> nums <- sub(".*:\\s+(\\S <file://s/>+).*", "\\1 <file://0.0.0.1/>",
x[markers])
> # get the 'p' (7th value on +4 line)
> pvalues_list <- strsplit(x[markers + 4], "\\s <file://s/>+")
> # separate out the 7th value (really 8th since first is blank)
> pvalues <- sapply(pvalues_list, '[', 8)
> # assume data structured well
> names(pvalues) <- nums
> pvalues
     s_1      s_2      s_3
 "4e-05" "0.1702" "0.0540"
>


On Fri, Mar 26, 2010 at 3:14 PM, <lixxx...@umn.edu> wrote:

> Dear R listers,
>
> I have a data file looks like the following:
>
> Testing marker:                           s_1
> ---------------------------------------------
>
> Allele   df(0) -LnLk(0)   df(T) -LnLk(T)   ChiSq       p
>     3 7995 29320.30 7994 29311.85 16.90 4e-05 (2229/8000 probands)
>
> Testing marker:                           s_2
> ---------------------------------------------
>
> Allele   df(0) -LnLk(0)   df(T) -LnLk(T)   ChiSq       p
>     3 7995 29339.25 7994 29338.31 1.88 0.1702 ( 121/8000 probands)
>
> Testing marker:                           s_3
> ---------------------------------------------
>
> Allele   df(0) -LnLk(0)   df(T) -LnLk(T)   ChiSq       p
>     3 7995 29340.83 7994 29338.97 3.71 0.0540 (2429/8000 probands)
>
> There are 10,000 testing markers, s_1 to s_10000. I want to read in all the
> 'p' values of the testing markers from this file. How can I do this?
>
> Thank you!
>
> xiang
>
> ______________________________________________
> 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<http://www.r-project.org/posting-guide.html>
> and provide commented, minimal, self-contained, reproducible code.
>



-- 
Jim Holtman
Cincinnati, OH
+1 513 646 9390

What is the problem that you are trying to solve?

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