Try this also:

library(gsubfn)
strapply(as.character(mynumber), "[0-9]", simplify = as.numeric)

On Tue, Dec 9, 2008 at 3:48 PM, Gustavo Carvalho
<[EMAIL PROTECTED]<[EMAIL PROTECTED]>
> wrote:

> Hello,
>
> Anyone knows how can I do this in a cleaner way?
>
> mynumber = 1001
> as.numeric(unlist(strsplit(as.character(mynumber),"")))
> [1] 1 0 0 1
>
> Thanks in advance,
>
> Gustavo
>
> ______________________________________________
> 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.

Reply via email to