Standardize column


I have a dataset in the form:

df <- data.frame(name = c("Tom", "Henry", "Linda", "Olivia"), 
                 values= c(2.732, 4.946, 1.235, 3.337))

The values range between 1 (being the highest score) and 5 (being the lowest score). I have a 2-fold task:

  1. I need to standardize this between 0 and 1 (cannot get the 'standardize' function to work..)
  2. Need to flip the highest and lowest .. ie. those scoring 1 should be 1 when standardized, and those scoring 5 should be 0. In this example, I basically want Linda to be 1 and Henry at 0, with Tom and Olivia's standardized scoring falling somewhere in the middle.

Many thanks!


df <- data.frame(name = c("Tom", "Henry", "Linda", "Olivia"), 
                  values= c(2.732, 4.946, 1.235, 3.337))
df$Std <- 1-(df$values-1)/4
    name values     Std
1    Tom  2.732 0.56700
2  Henry  4.946 0.01350
3  Linda  1.235 0.94125
4 Olivia  3.337 0.41575

Thank you, but I do specifically need it to be standardized

I understand "standardize", when not further qualified, to mean shifting the data to have a mean of zero and a standard deviation of one. That is not compatible with also restricting the data to the interval [0,1]. I am obviously not understanding what you mean. Can you unconfuse me?

I think the idea here is that if your original values are between 0 and 5, you are finding the straight line that fits
x y
= =
5 0
0 1

which is y = (- 1/4)*(x - 5)

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.