[R] From numeric vector to string vector

jim holtman jholtman at gmail.com
Sun Feb 13 16:51:09 CET 2011


Is this what you want:

> Vect <- c(12.234, 234.5675, 1.5)
> sprintf("%07.3f", Vect)
[1] "012.234" "234.567" "001.500"
>


On Sun, Feb 13, 2011 at 10:43 AM, Bogaso Christofer
<bogaso.christofer at gmail.com> wrote:
> Hi there, I have a numeric vector let say:
>
>
>
> Vect <- c(12.234, 234.5675, 1.5)
>
>
>
> Now I want a string vector like:
>
>
>
> changedVec <- c("012.234", "234.568", "001.500")
>
>
>
> Would be grateful if somebody help me how can I do that.
>
>
>
> Thanks and regards,
>
>
>        [[alternative HTML version deleted]]
>
> ______________________________________________
> R-help at 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.
>



-- 
Jim Holtman
Data Munger Guru

What is the problem that you are trying to solve?



More information about the R-help mailing list