[R] How to cut data elements included in a text line

Henrique Dallazuanna wwwhsd at gmail.com
Fri Jul 18 20:07:14 CEST 2008


Try this:

na.omit(as.numeric(unlist(strsplit("\talpha0\t-0.638\t0.4043\t0.4043\t-2.215\t-0.5765\t-0.137\t501\t2000",
"\t"))))


On Fri, Jul 18, 2008 at 1:44 PM, Christine A.
<adrion at ibe.med.uni-muenchen.de> wrote:
>
> Hello,
>
> assume I have an "unstructured" text line from a connection. Unfortunately,
> it is in string format:
>
> R> x
> [1] "\talpha0\t-0.638\t0.4043\t0.4043\t-2.215\t-0.5765\t-0.137\t501\t2000"
>
>
> How can I extract the data included in this string object "x" in order to
> get the elements for the parameter vector called "alpha0", i.e.
>  -0.638   0.4043   0.0467  0.4043 -2.215  -0.5765  -0.137 501
>
>
> Any hints how to handle this would be appreciated.
> Best regards,
> Christine
>
>
> --
> Christine Adrion, Dipl.-Stat., MPH
>
> Ludwig-Maximilians-Universitaet Muenchen
> IBE  - Institut fuer Medizinische Informations-
> verarbeitung, Biometrie und Epidemiologie
> Marchioninistr. 15
> D- 81377 Muenchen
>
> Tel.:      +49 (0)89 7095 - 4483
> eMail:    adrion at ibe.med.uni-muenchen.de
> web:     http://ibe.web.med.uni-muenchen.de
>
>
>
>
>
>
>
>
> --
> View this message in context: http://www.nabble.com/How-to-cut-data-elements-included-in-a-text-line-tp18533319p18533319.html
> Sent from the R help mailing list archive at Nabble.com.
>
>        [[alternative HTML version deleted]]
>
> ______________________________________________
> R-help at 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.
>



-- 
Henrique Dallazuanna
Curitiba-Paraná-Brasil
25° 25' 40" S 49° 16' 22" O



More information about the R-help mailing list