Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
167 views
in Technique[技术] by (71.8m points)

r - Rating of locations based on a parameter

I am looking for a method that utilizes the traffic count and based on that gives a rating for that particular location ratings should lie between 0 to 10. I can simply just give rankings 1 to 30 where rank 1 given to the location where most of the traffic occurs. I might need something which scales it between 0 to 10. Any suggestions?

> dput(Data)
structure(list(Traffic.Views = c(3175760L, 2949940L, 2685756L, 
2535156L, 2437236L, 2210328L, 2085276L, 1974840L, 1961424L, 1923308L, 
1844408L, 1781592L, 1761252L, 1675820L, 1582748L, 1475928L, 1399336L, 
1311940L, 1309980L, 1305544L, 1160140L, 1144348L, 1137584L, 1106904L, 
946304L, 931992L, 891176L, 815812L, 789788L, 662652L), Names = c("df01", 
"df02", "df03", "df04", "df05", "df06", "df07", "df08", "df09", 
"df10", "df11", "df12", "df13", "df14", "df15", "df16", "df17", 
"df18", "df19", "df20", "df21", "df22", "df23", "df24", "df25", 
"df26", "df27", "df28", "df29", "df30")), row.names = c(NA, -30L
), class = "data.frame")

enter image description here

question from:https://stackoverflow.com/questions/66058364/rating-of-locations-based-on-a-parameter

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

You can use :

rating_0_10 <- function(x) (x-min(x))/(max(x)-min(x)) * 10
Data$scaled <- rating_0_10(Data$Traffic.Views)
Data

#   Traffic.Views Names     scaled
#1        3175760  df01 10.0000000
#2        2949940  df02  9.1014314
#3        2685756  df03  8.0502072
#4        2535156  df04  7.4509492
#5        2437236  df05  7.0613121
#6        2210328  df06  6.1584142
#7        2085276  df07  5.6608152
#8        1974840  df08  5.2213753
#9        1961424  df09  5.1679912
#10       1923308  df10  5.0163224
#11       1844408  df11  4.7023685
#12       1781592  df12  4.4524151
#13       1761252  df13  4.3714795
#14       1675820  df14  4.0315339
#15       1582748  df15  3.6611877
#16       1475928  df16  3.2361363
#17       1399336  df17  2.9313663
#18       1311940  df18  2.5836056
#19       1309980  df19  2.5758065
#20       1305544  df20  2.5581551
#21       1160140  df21  1.9795727
#22       1144348  df22  1.9167342
#23       1137584  df23  1.8898193
#24       1106904  df24  1.7677394
#25        946304  df25  1.1286901
#26        931992  df26  1.0717406
#27        891176  df27  0.9093282
#28        815812  df28  0.6094446
#29        789788  df29  0.5058915
#30        662652  df30  0.0000000

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...