[R] From numeric vector to string vector

Peter Ehlers ehlers at ucalgary.ca
Sun Feb 13 16:58:59 CET 2011


On 2011-02-13 07:43, Bogaso Christofer 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")

Just for completeness, let's add formatC to your options:

  formatC( Vect, digits=3, width=7, format="f", flag=0 )

Peter Ehlers

>
>
>
> 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.



More information about the R-help mailing list