Hi Sit,

# Read the data:
dat <- scan(textConnection("
0.293290E-05       0.117772E-05     -0.645205     *rs2282755*
 0.307521E-05           0.000314      0.412997     *rs1336838*
 0.484017E-05           0.218311      0.188669     *rs2660664
rs967785*
 0.977861E-05           0.070474      0.294653     *rs2660664*
 0.122767E-04       0.156325E-04      0.569826     *rs6870519*
 0.227205E-04           0.000189     -0.472862     *rs10488345*
 0.297239E-04       0.746393E-04     -0.480489     *rs2190208*
 0.392298E-04           0.001416     -0.434644     *rs12463130*
 0.459242E-04           0.000348     -0.453926     *rs8038015*
 0.479103E-04       0.909700E-04     -0.480937     *rs5760687*
 0.480441E-04       0.570455E-04     -0.490767     *rs13067678*
 0.500883E-04       0.282350E-04      0.516482     *rs8095161*
 0.747011E-04           0.164626      0.217575     *rs1336838
rs2660664*
 0.801069E-04           0.006909     -0.368615     *rs4894786*
 0.911204E-04       0.297226E-05     -0.518989     *rs7879285*
 0.950313E-04           0.154268      0.210027     *rs5972224*
     0.000139           0.112114     -0.288319     *rs10488345
rs12463130*
     0.000194           0.403270      0.280580     *rs967785*
     0.001458           0.067065     -0.291453     *rs4894786
rs967785*
     0.025459           0.001126      0.496227     *rs2660664
rs7879285"), what="character")
closeAllConnections()

# Get the words starting with "rs"
dat[grep("^rs", dat)]



cheers,
Remko


> Date: Tue, 11 Nov 2008 16:11:22 -0800
> From: [EMAIL PROTECTED]
> To: r-help@r-project.org
> Subject: [R] scanning text file to extract particular word
> 
> Hi all,
> 
> I'm wondering if you know a function that allow me to scan through a whole
> text file, extracting words start with "rs".
> 
> For example, below is format of the text file, I would like to extract those
> words start with "rs"
> 
>  ORDINARY REGRESSION: BEST LASSO PREDICTORS
> 
>  PREDICTOR            MARGINAL        LEAVE-ONE-OUT
>    NAME               P-VALUE             INDEX        ESTIMATE
> 
>  *rs2282755*          0.293290E-05      0.148870E-05    -0.646161
> * rs1336838          *0.307521E-05      0.133489E-04     0.463460
> * rs2660664          *0.977861E-05      0.531800E-04     0.520049
> * rs6870519          *0.122767E-04      0.133453E-04     0.568136
> * rs10488345         *0.227205E-04      0.326049E-04    -0.522453
> * rs2190208          *0.297239E-04      0.803506E-04    -0.479791
> * rs12463130         *0.392298E-04      0.274131E-04    -0.511305
> * rs8038015          *0.459242E-04          0.000359    -0.451897
> * rs5760687          *0.479103E-04          0.000117    -0.473533
> * rs13067678         *0.480441E-04      0.344974E-04    -0.505946
> * rs8095161          *0.500883E-04      0.442157E-04     0.505334
> * rs4894786          *0.801069E-04          0.000111    -0.468523
> * rs7879285          *0.911204E-04          0.000192    -0.386826
> * rs5972224          *0.950313E-04          0.148923     0.355116
> * rs967785               *0.000194          0.220069     0.179979
> 
>       ORDINARY REGRESSION: BEST INTERACTION PREDICTORS
> 
>   MARGINAL          LEAVE-ONE-OUT                  INTERACTION
>   P-VALUE               INDEX         ESTIMATE       MEMBERS
> 
>  0.293290E-05       0.117772E-05     -0.645205     *rs2282755*
>  0.307521E-05           0.000314      0.412997     *rs1336838*
>  0.484017E-05           0.218311      0.188669     *rs2660664
> rs967785*
>  0.977861E-05           0.070474      0.294653     *rs2660664*
>  0.122767E-04       0.156325E-04      0.569826     *rs6870519*
>  0.227205E-04           0.000189     -0.472862     *rs10488345*
>  0.297239E-04       0.746393E-04     -0.480489     *rs2190208*
>  0.392298E-04           0.001416     -0.434644     *rs12463130*
>  0.459242E-04           0.000348     -0.453926     *rs8038015*
>  0.479103E-04       0.909700E-04     -0.480937     *rs5760687*
>  0.480441E-04       0.570455E-04     -0.490767     *rs13067678*
>  0.500883E-04       0.282350E-04      0.516482     *rs8095161*
>  0.747011E-04           0.164626      0.217575     *rs1336838
> rs2660664*
>  0.801069E-04           0.006909     -0.368615     *rs4894786*
>  0.911204E-04       0.297226E-05     -0.518989     *rs7879285*
>  0.950313E-04           0.154268      0.210027     *rs5972224*
>      0.000139           0.112114     -0.288319     *rs10488345
> rs12463130*
>      0.000194           0.403270      0.280580     *rs967785*
>      0.001458           0.067065     -0.291453     *rs4894786
> rs967785*
>      0.025459           0.001126      0.496227     *rs2660664
> rs7879285
> 
> *Thanks,
> Sit
> 
>       [[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.

_________________________________________________________________

l.

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