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

From: Jorge Ivan Velez <jorgeivanvelez_at_gmail.com>
Date: Fri, 18 Jul 2008 14:10:53 -0400

Dear Christine,

Try

x="\talpha0\t-0.638\t0.4043\t0.4043\t-2.215\t-0.5765\t-0.137\t501\t2000" res=unlist(strsplit(x,"[\t]"))
as.numeric(res[-c(1,2,length(res)-1,length(res))])

HTH, Jorge

On Fri, Jul 18, 2008 at 12: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.
>

        [[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. Received on Fri 18 Jul 2008 - 18:35:24 GMT

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Fri 18 Jul 2008 - 19:32:03 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.

list of date sections of archive