Dear Tim,
I am using the result of cumsum(), which has leading zeroes,
(like 0 0 1 1 2 2), coerce it to a character vector, collapse it, and then
coerce it back to an integer to compare it in a switch statement. But now I got
it. I can just use the collapsed character value...T
Can you tell us why you want to do this? Is there something special about 09098
versus 9098 or 009098? In any mathematical operation these are all the same
number.
Tim
From: akshay kulkarni
Sent: Sunday, September 11, 2022 2:58 PM
To: Ebert,Timothy Aaron ; R help Mailing list
Subject: Re
You seem to be confusing **what** is printed with *how* it is printed.
> print(9) ## a numeric (not an integer, actually. That would be 9L)
[1] 9 ## default print format
> print(formatC(9, width =2, flag = "0")) ## format specification
[1] "09"
> print(formatC(9, width =2, flag = "0"), quote = F
What you're asking for doesn't make sense: 9098 and 09098 are the same
9098L == 09098L
If you mean specifically while printing, you could use sprintf:
cat(sprintf("%05d", 9098))
On Sun., Sep. 11, 2022, 14:58 akshay kulkarni,
wrote:
> Dear Tim,
> So there is no way to coerce
On 9/11/22 12:22, akshay kulkarni wrote:
> Dear members,
> I came across this queer thing during my analysis:
>> as.integer("09098")
> 9098
>
> Any idea on how to retain the "0"?
Don't use as.integer(), which has performed precisely the service that
it advertises?
I certainly wouldn't call this
5 matches
Mail list logo