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

2008-07-18 Thread Christine A.
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

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

2008-07-18 Thread Henrique Dallazuanna
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. [EMAIL PROTECTED] wrote: Hello, assume I have an unstructured text line from a connection. Unfortunately, it is in string

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

2008-07-18 Thread Jorge Ivan Velez
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. [EMAIL PROTECTED] wrote: Hello, assume I have an

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

2008-07-18 Thread Gabor Grothendieck
strapply in gsubfn finds matches of the indicated regexp, in this case a \t followed by one or more minus, dot or digit, and with backref of -1 it passes the backreference, i.e. portion of the match within (..), to the function in the third arg. See http://gsubfn.googlecode.com library(gsubfn)