Created
September 14, 2016 18:41
-
-
Save mattsedlar/19f58a00be61cf777c5758d27f965664 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# script detailing process for weighted scores in Runner's World dataset | |
# reading in the csv containing the table | |
dat = read.csv("data/runners-world-data.csv") | |
# remove the ranking column since rows are id'd 1:x | |
dat = dat[,2:7] | |
# weights provided by Runner's World | |
weights = c(.4,.2,.2,.1,.1) | |
# empty vector | |
weighted.total = c() | |
# for loop to calculate the weighted average for each row | |
for(i in 1:nrow(dat)) { | |
weighted.total = c(weighted.total, sum(dat[i,2:6] * weights)) | |
} | |
# add column to dataframe | |
dat$Weighted.Score = weighted.total |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment