Re: [R] From numeric vector to string vector

2011-02-13 Thread jim holtman
just using as.character does not add the leading/trailing zeros: > Vect <- c(12.234, 234.5675, 1.5) > as.character(Vect) [1] "12.234" "234.5675" "1.5" > On Sun, Feb 13, 2011 at 12:04 PM, Sascha Vieweg wrote: > On 11-02-13 10:48, David Winsemius wrote: > >> On Feb 13, 2011, at 10:43 AM, Bogaso

Re: [R] From numeric vector to string vector

2011-02-13 Thread Sascha Vieweg
On 11-02-13 10:48, David Winsemius wrote: On Feb 13, 2011, at 10:43 AM, 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") ?sprintf Just for my own un

Re: [R] From numeric vector to string vector

2011-02-13 Thread Peter Ehlers
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,

Re: [R] From numeric vector to string vector

2011-02-13 Thread jim holtman
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 wrote: > Hi there, I have a numeric vector let say: > > > > Vect <- c(12.234, 234.5675, 1.5) > > > > Now I want a string ve

Re: [R] From numeric vector to string vector

2011-02-13 Thread Dieter Menne
Bogaso wrote: > > Vect <- c(12.234, 234.5675, 1.5) > Now I want a string vector like: > changedVec <- c("012.234", "234.568", "001.500") > sprintf("%06.3f", c(12.234, 234.5675, 1.5)) Dieter -- View this message in context: http://r.789695.n4.nabble.com/From-numeric-vector-to-string-vector

Re: [R] From numeric vector to string vector

2011-02-13 Thread David Winsemius
On Feb 13, 2011, at 10:43 AM, 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") ?sprintf David Winsemius, MD West Hartford, CT _

[R] From numeric vector to string vector

2011-02-13 Thread Bogaso Christofer
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