[R] String to array
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 PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] String to array
Romildo Martins romildo.martins at 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-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.
Re: [R] String to array
Romildo Martins romildo.mart...@gmail.com 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 Thanks, RMB - x - 0 - 13 x [1] 0 - 13 as.numeric(unlist(strsplit(x, -))) [1] 0 13 HTH __ 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.
Re: [R] String to array
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 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 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@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.
Re: [R] String to array
Try this: library(gsubfn) strapply(11 - 23, \\d{1,3}, simplify = as.numeric) On Thu, Dec 9, 2010 at 12:24 PM, Romildo Martins romildo.mart...@gmail.comwrote: 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 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 [[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.