[R] String to array

Keith Jewell k.jewell at campden.co.uk
Thu Dec 9 15:38:29 CET 2010


"Romildo Martins" <romildo.martins at gmail.com> wrote in message 
news:AANLkTinBiaExcoBZYQDbtr62XR9q=KjVWAAzaQi-kKd0 at 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



More information about the R-help mailing list