Character and Numeric vectors, preserve decimal points in R

18 views Asked by At

I am trying to convert a numeric vector into a character object but I want maintain my decimal points. For example, observe the following code:

v <- c(2, 3.55)

When typing the vector into my console I will observe

2.00 3.55

However, if I use the as.character(v) function it returns

"2" "3.55"

I would like to instead have it return

"2.00" "3.55"

I have included a picture of the problem for completeness/clarity. Thanks in advance.

enter image description here

0

There are 0 answers