Re: [R] String to array

2010-12-09 Thread Henrique Dallazuanna
Try this: library(gsubfn) strapply("11 - 23", "\\d{1,3}", simplify = as.numeric) On Thu, Dec 9, 2010 at 12:24 PM, Romildo Martins wrote: > Hello, > > how convert x in xarray (numbers)? > > > x > [1] "0 - 13" > > y > [1] "11 - 23" > > z > [1] "220 - 9" > > xarray > [1] 0 13 > > yarray > [1] 11 2

Re: [R] String to array

2010-12-09 Thread Jorge Ivan Velez
Try f <- function(string) as.numeric(strsplit(string, "- ")[[1]]) f(x) f(y) f(z) HTH, Jorge On Thu, Dec 9, 2010 at 9:24 AM, Romildo Martins <> wrote: > Hello, > > how convert x in xarray (numbers)? > > > x > [1] "0 - 13" > > y > [1] "11 - 23" > > z > [1] "220 - 9" > > xarray > [1] 0 13 > > ya

Re: [R] String to array

2010-12-09 Thread Keith Jewell
"Romildo Martins" wrote in message news:aanlktinbiaexcobzyqdbtr62xr9q=kjvwaazaqi-k...@mail.gmail.com... > Hello, > > how convert x in xarray (numbers)? > >> x > [1] "0 - 13" >> y > [1] "11 - 23" >> z > [1] "220 - 9" >> xarray > [1] 0 13 >> yarray > [1] 11 23 >> zarray > [1] 220 9 > > > > Than

Re: [R] String to array

2010-12-09 Thread Ben Bolker
Romildo Martins gmail.com> writes: > how convert x in xarray (numbers)? > > > x > [1] "0 - 13" > > y > [1] "11 - 23" > > z > [1] "220 - 9" > > xarray > [1] 0 13 > > yarray > [1] 11 23 > > zarray > [1] 220 9 Is as.numeric(unlist(strsplit("0 - 13","-"))) what you want?

[R] String to array

2010-12-09 Thread Romildo Martins
Hello, how convert x in xarray (numbers)? > x [1] "0 - 13" > y [1] "11 - 23" > z [1] "220 - 9" > xarray [1] 0 13 > yarray [1] 11 23 > zarray [1] 220 9 Thanks, RMB __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help