[image removed]
Re: [R] More elegant magnitude method
David Winsemius
to:
Jonathan P Daily
12/07/2010 02:50 PM
Cc:
r-help
On Dec 7, 2010, at 2:43 PM, Jonathan P Daily wrote:
I have a need to find the order of number to get a scaling parameter
as a
power of 10. I have a function that works *so far*, but it is ugly and
probably buggy. In the interest of avoiding code-based outliers in my
data, I thought I would ask if anyone here has a better way.
+ length(charToRaw(format(trunc(x), scientific = F)))-1}
a <- 123456789
b <- 1E15
c <- 12.345
scl(a)
scl<- function(x) trunc(log(x,10))
[1] 1
Seems mathematically clearer.
--
David Winsemius, MD
West Hartford, CT