I have a set of athlete records from openpowerlifting.org and I want to retrieve all of the athletes from a certain division. The entries are of the form "Meet ID Name Sex Equipment Age Divison ..." and I wish to extract all those who participated in a ceratain division. Here is my code:
powerlift <- read.csv("openpowerlifting.csv",header = TRUE,fill = TRUE,stringsAsFactors = FALSE )
n = length(powerlift$TotalKg)
UPA_Open = as.data.frame(matrix(c(rep(0,n*17)),ncol=17))
j=1
for(i in 1:n){
if(powerlift$Divison[i]=="UPA Open"){
UPA_Open[j,] = powerlift[i,]
j = j + 1
}
}
I encounter the following problem:
Error in if (powerlift$Divison[i] == "UPA Open") { :
argument is of length zero
and investigating the data set after execution
> i
[1] 1
> powerlift$Division[i]
[1] "Mst 45-49"
> powerlift$Division[i] == "Mst 45-49"
[1] TRUE
so it stopped after attempting one iteration, claiming that the data was null which is was not. What is going on?