I am a beginner in R trying to analyze NBA draft data. I am trying to reassign the value of how many people attended the college(freq
) to the name of the college(y2015$college_name
) in the data set.
Here is some example code:
urlfile <- "https://raw.githubusercontent.com/kshvmdn/nbadrafts/master/datasets/2015_nbadraft.csv"
y2015 <- read.csv(url(urlfile))
freq <- count(y2015$college_name)
if(draft$college_name[i] == freq[i, 1]){
draft$college_name[i] <- freq[i, 2]
} else {
draft$college_name[i] <- 0
}
I just picked i to be the variable for no reason and I keep getting the error: object 'i' not found
What do I do?