Neil Neil - 3 months ago 22
R Question

How to scale a number on 1-100 scale

I have a dataframe in R which has following values

count Score
2 99
89 91
124 87
670 70
2111 10
34 97


and so on.
largest number is 2111 and smallest is 2
Now,I want to get those number on 1-100 scale. Smallest being 100 and largest being 1

I have put in some approximate values in
Score
column. How can we do it in R

Answer Source

We can use rescale

round(scales::rescale(-df1$count, to = c(1, 100)))