1
$\begingroup$

Okay, I know this will be too easy for this forum. Nevertheles, I want to ask this.

I have a sequence of numbers:

c(9, 7, 23, 26, 11, 12, 28, 34, 20, 32, 41, 78, 37, 60, 41, 33, 
31, 55, 58, 58, 71, 55, 43, 65, 56, 32, 130, 38, 43, 40, 50, 
56, 69, 45, 70, 36, 51, 57, 56, 60)

And I would like to have a convenient way to convert the numbers to percentages with the highest value being 100% and either the lowes value being 0% OR zero being 0%.

How would I do that with a formula or seomthing?

Thank you very much! Regards!

  • 0
    What do you mean "OR zero being $0\%$"? There's no "zero" in that list of values!!!2017-01-08
  • 0
    yes I know.... but the data are counts of something (pollen) and I'm not sure yet if I want to include the case that nothing was found. Maybe a mathematician would say this is nonsense?2017-01-08

2 Answers 2

1

Let the smallet value that you want to map to $0$ be $m$ and the biggest number in your list be $M$.

you want to construct the real line that connects $(m, 0)$ and $(M,100)$

$$\frac{y-0}{x-m}=\frac{100-0}{M-m}$$

Hence $y=\frac{100(x-m)}{M-m}$, where $x$ is your original input and $y$ is the new output.

  • 0
    Wow thank you very much! If this is true (I cannot judge right now) then this is awesome! I can basically just type this into a programming language:)Thx!2017-01-08
0

Find the minimum value, call it $m$.

Find the maximum value, call it $M$.

Replace every value $x$ with $(x-m)\times\frac{100-0}{M-m}+m$.

  • 0
    Thanks also :) This is very helpful!2017-01-08
  • 0
    @VeraMarya: You're welcome :)2017-01-08