Home > Back-end >  How to transform in Percentual value
How to transform in Percentual value

Time:03-08

How do I adjust my Scor column, as I notice that the others are in percentage format, but Scor is not.

df1<-structure(list(Scor = c(7464.65871998132, 7464.65871998132, 
7464.65871998132, 6828.03114705642, 6828.03114705642, 4283.33056756974, 
4283.33056756974, 4283.33056756974, 4283.33056756974, 4283.33056756974, 
2471.01407552018, 2471.01407552018, 1167.72213085951, 1759.83563490657, 
2832.42425394852, 2216.93502047899, 2216.93502047899, 2216.93502047899, 
2216.93502047899, 2216.93502047899, 2216.93502047899, 2216.93502047899, 
2216.93502047899, 2216.93502047899, 2216.93502047899, 1382.78244210074, 
1382.78244210074, 1382.78244210074, 1382.78244210074, 225.532020592308, 
225.532020592308, 451.757369238554, 451.757369238554, 451.757369238554, 
391.4333, 391.4333, 391.4333, 391.4333), Performance = c(0.717983998645269, 
0.717983998645269, 0.717983998645269, 0.728999753129052, 0.728999753129052, 
0.786965354287025, 0.786965354287025, 0.786965354287025, 0.786965354287025, 
0.786965354287025, 0.850074652422915, 0.850074652422915, 0.915840124863607, 
0.883139402208456, 0.835366766790403, 0.861211447058532, 0.861211447058532, 
0.861211447058532, 0.861211447058532, 0.861211447058532, 0.861211447058532, 
0.861211447058532, 0.861211447058532, 0.861211447058532, 0.861211447058532, 
0.903336851097558, 0.903336851097558, 0.903336851097558, 0.903336851097558, 
0.981191034215198, 0.981191034215198, 0.785270862340655, 0.785270862340655, 
0.785270862340655, 0.804079828125457, 0.804079828125457, 0.804079828125457, 
0.804079828125388), score = c(0.324701873490657, 0.324701873490657, 
0.324701873490657, 0.348051447072024, 0.348051447072024, 0.528241884225376, 
0.528241884225376, 0.528241884225376, 0.528241884225376, 0.528241884225376, 
0.713363517626057, 0.713363517626057, 0.861245569166058, 0.792956247672247, 
0.67415167385565, 0.741455966636511, 0.741455966636511, 0.741455966636511, 
0.741455966636511, 0.741455966636511, 0.741455966636511, 0.741455966636511, 
0.741455966636511, 0.741455966636511, 0.741455966636511, 0.836255759358446, 
0.836255759358446, 0.836255759358446, 0.836255759358446, 0.972845769144406, 
0.972845769144406, 0.668098499995622, 0.668098499995622, 0.668098499995622, 
0.675298126509343, 0.675298126509343, 0.675298126509343, 0.67529812650932
), Q = c(0.984893346832548, 0.984893346832548, 0.984893346832548, 
0.898279272093836, 0.898279272093836, 0.552069187025303, 0.552069187025303, 
0.552069187025303, 0.552069187025303, 0.552069187025303, 0.305500984879433, 
0.305500984879433, 0.128186286770186, 0.208744159967084, 0.354671346857167, 
0.270933172866875, 0.270933172866875, 0.270933172866875, 0.270933172866875, 
0.270933172866875, 0.270933172866875, 0.270933172866875, 0.270933172866875, 
0.270933172866875, 0.270933172866875, 0.157445543929907, 0.157445543929907, 
0.157445543929907, 0.157445543929907, 0, 0, 1, 1, 1, 0.984893346832548, 
0.984893346832548, 0.984893346832548, 0.984893346832602)), row.names = c(NA, 
38L), class = "data.frame")

> df1
        Scor Performance     score         Q
1  7464.6587   0.7179840 0.3247019 0.9848933
2  7464.6587   0.7179840 0.3247019 0.9848933
3  7464.6587   0.7179840 0.3247019 0.9848933
4  6828.0311   0.7289998 0.3480514 0.8982793
5  6828.0311   0.7289998 0.3480514 0.8982793
6  4283.3306   0.7869654 0.5282419 0.5520692
7  4283.3306   0.7869654 0.5282419 0.5520692
8  4283.3306   0.7869654 0.5282419 0.5520692
9  4283.3306   0.7869654 0.5282419 0.5520692
10 4283.3306   0.7869654 0.5282419 0.5520692
11 2471.0141   0.8500747 0.7133635 0.3055010
12 2471.0141   0.8500747 0.7133635 0.3055010
13 1167.7221   0.9158401 0.8612456 0.1281863
14 1759.8356   0.8831394 0.7929562 0.2087442
15 2832.4243   0.8353668 0.6741517 0.3546713
16 2216.9350   0.8612114 0.7414560 0.2709332
17 2216.9350   0.8612114 0.7414560 0.2709332
18 2216.9350   0.8612114 0.7414560 0.2709332
19 2216.9350   0.8612114 0.7414560 0.2709332
20 2216.9350   0.8612114 0.7414560 0.2709332
21 2216.9350   0.8612114 0.7414560 0.2709332
22 2216.9350   0.8612114 0.7414560 0.2709332
23 2216.9350   0.8612114 0.7414560 0.2709332
24 2216.9350   0.8612114 0.7414560 0.2709332
25 2216.9350   0.8612114 0.7414560 0.2709332
26 1382.7824   0.9033369 0.8362558 0.1574455
27 1382.7824   0.9033369 0.8362558 0.1574455
28 1382.7824   0.9033369 0.8362558 0.1574455
29 1382.7824   0.9033369 0.8362558 0.1574455
30  225.5320   0.9811910 0.9728458 0.0000000
31  225.5320   0.9811910 0.9728458 0.0000000
32  451.7574   0.7852709 0.6680985 1.0000000
33  451.7574   0.7852709 0.6680985 1.0000000
34  451.7574   0.7852709 0.6680985 1.0000000
35  391.4333   0.8040798 0.6752981 0.9848933
36  391.4333   0.8040798 0.6752981 0.9848933
37  391.4333   0.8040798 0.6752981 0.9848933
38  391.4333   0.8040798 0.6752981 0.9848933

CodePudding user response:

You could just do:

library(dplyr)
df1 %>%
  mutate(Scor = Scor / max(Scor))
  •  Tags:  
  • r
  • Related