Displaying 20 results from an estimated 55 matches for "prettynum".
2019 Mar 21
3
prettyNum digits=0 not compatible with scientific notation
R developers,
Seems I get a bad result ("%#4.0-1e" in particular) when trying to use prettyNum digits=0 with scientific notation. I tried on both my Linux box and on an online R evaluator and saw the same problem, so it's not limited to my box at least. I see the problem in both R 3.5.3 and R 3.3.2.
options(scipen=-100)
prettyNum(1, digits=0)
[1] "%#4.0-1e"
prettyNum(2, digits...
2019 Mar 22
2
prettyNum digits=0 not compatible with scientific notation
FWIW, it doesn't seem to be happening on Mac OS:
> format(2^30, digits=0)
[1] "1.e+09"
> prettyNum(12345.6, digits=0)
[1] "1.e+04"
A glibc misfeature?
-pd
> On 22 Mar 2019, at 10:10 , Martin Maechler <maechler at stat.math.ethz.ch> wrote:
>
> Thank you, Robert for raising this here !
>
>>>>>> Robert McGehee
>>>>>> on Thu, 2...
2019 Mar 22
0
prettyNum digits=0 not compatible with scientific notation
Thank you, Robert for raising this here !
>>>>> Robert McGehee
>>>>> on Thu, 21 Mar 2019 20:56:19 +0000 writes:
> R developers,
> Seems I get a bad result ("%#4.0-1e" in particular) when trying to use prettyNum digits=0 with scientific notation. I tried on both my Linux box and on an online R evaluator and saw the same problem, so it's not limited to my box at least. I see the problem in both R 3.5.3 and R 3.3.2.
> options(scipen= -100)
The above is extreme: You're basically setting an op...
2019 Mar 22
0
prettyNum digits=0 not compatible with scientific notation
>>>>> peter dalgaard
>>>>> on Fri, 22 Mar 2019 17:30:19 +0100 writes:
> FWIW, it doesn't seem to be happening on Mac OS:
>> format(2^30, digits=0)
> [1] "1.e+09"
>> prettyNum(12345.6, digits=0)
> [1] "1.e+04"
> A glibc misfeature?
It seems (and note we are talking about format.default() here,
of which prettyNum() is only a wrapper in this case):
Here's an example that shows that 'digits=0' actually can make
"sense"...
2025 May 23
1
Bug in prettyNum
? Fri, 23 May 2025 11:47:33 +0000
Marttila Mikko via R-devel <r-devel at r-project.org> ?????:
> When called with a numeric vector, the `replace.zero` argument is
> disregarded.
>
> > prettyNum(0, zero.print = "- ", replace.zero = TRUE)
> [1] "-"
> Warning message:
> In .format.zeros(x, zero.print, replace = replace.zero) :
> 'zero.print' is truncated to fit into formatted zeros; consider
> 'replace=TRUE'
> Please see below a patc...
2025 May 26
1
Bug in prettyNum
Thank you, Marttila and Ivan,
As the original author of prettyNum() {etc ..},
I will commit such a bug fix to R-devel (and probably port it to
R 4.5.0 patched) quite soon
(but not yet today).
Best regards,
Martin Maechler
>>>>> Ivan Krylov via R-devel
>>>>> on Fri, 23 May 2025 17:14:57 +0300 writes:
> ? Fri, 23 May 20...
2025 May 23
1
Bug in prettyNum
Dear list,
I'd like to report a bug in `prettyNum()`. When called with a numeric vector, the `replace.zero` argument is disregarded.
> prettyNum(0, zero.print = "- ", replace.zero = TRUE)
[1] "-"
Warning message:
In .format.zeros(x, zero.print, replace = replace.zero) :
'zero.print' is truncated to fit into format...
2025 May 27
1
Bug in prettyNum
...Heather Turner's R Dev Container, see instructions here
https://contributor.r-project.org/r-dev-env/container_setup/
Best
Toby
On Mon, May 26, 2025 at 6:28?PM Martin Maechler <maechler at stat.math.ethz.ch>
wrote:
> Thank you, Marttila and Ivan,
>
> As the original author of prettyNum() {etc ..},
> I will commit such a bug fix to R-devel (and probably port it to
> R 4.5.0 patched) quite soon
> (but not yet today).
>
> Best regards,
>
> Martin Maechler
>
> >>>>> Ivan Krylov via R-devel
> >>>>> on Fri, 23 May 2025 17:...
2025 May 23
1
Formatting zeroes with prettyNum
You fed it two characters, "dash" and "space" and it only wanted one character so it truncated to the first character and warned you that that's what it did.
If you had your space before the dash, it would have used that as your replacement character
> prettyNum(0, zero.print = " - ", replace = TRUE)
[1] " "
Warning message:
In .format.zeros(x, zero.print, replace = replace.zero) :
'zero.print' is truncated to fit into formatted zeros; consider 'replace=TRUE'
When zero.print is only one character, it doesn't gi...
2025 May 23
1
Formatting zeroes with prettyNum
Dear list,
Have I stumbled upon a bug, or am I holding `prettyNum()` wrong? Please see below.
Best,
Mikko
> prettyNum(0, zero.print = "- ", replace.zero = TRUE)
[1] "-"
Warning message:
In .format.zeros(x, zero.print, replace = replace.zero) :
'zero.print' is truncated to fit into formatted zeros; consider 'replace=TRUE'...
2025 May 23
1
Formatting zeroes with prettyNum
Tim,
The purpose of the `replace.zero` argument is to allow longer replacements.
See for example the behaviour with a character vector input:
> prettyNum("0", zero.print = "- ", replace.zero = TRUE)
[1] "- "
I'm pretty sure this is a bug, and have now posted the relevant details on r-devel.
A fix would be below.
Best,
Mikko
diff --git a/src/library/base/R/format.R b/src/library/base/R/format.R
index 63fef83..1a...
2002 May 13
1
prettyNum inserts leading commas (PR#1548)
Under R-1.5.0 on Solaris 2.6:
R> prettyNum(123456789, big.mark=",")
[1] ",123,456,789"
and that bad behavior (leading comma) spills into formatC as well:
R> formatC(123456789, digits=0, format="f", big.mark=",")
[1] ",123,456,789"
Looks to me like a bug in src/library/base/R/form...
2018 May 25
4
options other than regex
...character with the character, followed by a decimal. The following big
of regex works...and illustrates the reformatting I'm after:
x <- '10110111'
print(x)
y <- sub("\\s+$", "", gsub('(.{1})', '\\1.', x))
print(y)
I had a look at formatC or prettyNum as another way to get there from
here, but couldn't get it to work:
x <- '10110111'
hold <- prettyNum(as.numeric(x), big.mark = ".", big.interval = 1,
??????? format = "d", flag = "0", width = nchar(x))
print(hold)
I tried making big.mark a decim...
2008 Aug 07
1
Bug in format.default(): na.encode does not have any effect for (PR#12318)
...u/R/e2/devel/06/09/0360.html
It works for other (say character) classes!
> format(c("a", NA), na.encode=3DTRUE)
[1] "a " "NA"
> format(c("a", NA), na.encode=3DFALSE)
[1] "a" NA
I explored this a bit and found out that format.default() uses prettyNum(.I=
nternal(format(...)))
for formatting the logical, numeric, complex, ... classes. Simple tests (se=
e bellow) show that
.Internal(format()) does not obey the na.encode argument.
## Encode NA as "NA"
> .Internal(format(x=3Dc(1, NA), trim=3DFALSE, digits=3DNULL, nsmall=3D0, w=
idth=3...
2018 May 25
0
options other than regex
...a decimal. The following big of regex works...and
> illustrates the reformatting I'm after:
>
> x <- '10110111'
> print(x)
>
> y <- sub("\\s+$", "", gsub('(.{1})', '\\1.', x))
> print(y)
>
> I had a look at formatC or prettyNum as another way to get there from here,
> but couldn't get it to work:
>
> x <- '10110111'
> hold <- prettyNum(as.numeric(x), big.mark = ".", big.interval = 1,
> format = "d", flag = "0", width = nchar(x))
> print(hold)
>...
2019 Mar 22
1
prettyNum digits=0 not compatible with scientific notation
> On 22 Mar 2019, at 18:07 , Martin Maechler <maechler at stat.math.ethz.ch> wrote:
>
> gives (on Linux R 3.5.3, Fedora 28)
>
> d=10 d=7 d=2 d=1 d=0
> [1,] "123456" "123456" "123456" "1e+05" "%#4.0-1e"
> [2,] "12345.6" "12345.6" "12346"
2009 Nov 13
2
format (PR#14062)
...c(840,1000,1000,1000)
> R <- c(860,2500,2500,2000)
> L <- c(0.23,1,1,1.1)
> T <- c(0.2,0.2,0.3,0.175)
> I <- c(0.05,0.1,0.14,0.18)
> inputs <- cbind(C,R,L,T,I)
If I try the same format command, it does not:
> (format(c(inputs[1,]),digits=3, scientific=T))
Error in prettyNum(.Internal(format(x, trim, digits, nsmall, width, 3, :
invalid 'scientific' argument
Only if I change scientific to NA
> (format(c(inputs[1,]),digits=3, scientific=NA))
remark (not important for the problem):
but I need scientific because sometimes the strings get to long otherwise...
2010 Dec 30
5
Why is format(10000, big.mark = "\\,") not 10\,000?
Hi,
why does format(10000, big.mark = "\\,") not give me "10\,000"? How can I get this kind of "big.mark"?
Cheers,
Marius
2010 Aug 27
3
interpreting date-related error message
...(days of the year) that I would
like to convert to a date. There are no NA's and no missing values.
I did not insert leading zero's for numbers less than 100.
Using the syntax:
dat$doy.1 <- as.numeric(format(dat$doy, "%j" ))
I get the following error message:
Error in prettyNum(.Internal(format(x, trim, digits, nsmall, width,
3L, :
invalid 'trim' argument
.What is the error message telling me?
(Windows OS and R 2.11.1)
Thank you.
Toby
2010 Feb 15
2
Printing 2 digits after decimal point
Hi there,
i'm not getting along with the following problem.
I'd like to print a real number, e.g.
x <- 12.3
with exactly two digits after the decimal point, e.g.
12.30
I've tried the whole format(), formatC() and prettyNum() functions but
did not have any success with it.
This should work with all real numbers, in case even with 0.0 (-> 0.00).
For cracks this thing is pretty sure obvious, but I've spent the whole
morning with it.
Please help me!
Thanks a lot,
Tom