I apologize if the title is not clear, but I couldn’t explain it succinctly.
Given a vector of concentrations, I would like to round the maximum value to the next order of magnitude (i.e., 345 to 1000). Also, I would like to round the minimum value to the lower order of magnitude (i.e., 3.2 to 1). These concentrations may also be below 1 so for example 0.034 would need to be rounded to 0.01.
Any ideas?
I’m not sure about R, but this is a simple process to describe algorithmically.
Take the base 10 logarithm of the number, and apply a ceiling or floor to the result. Raise 10 to that power. Done.
You need a special case for 0 because you can’t take a logarithm of 0.