I currently have this code: for(j in 2:n){ for(i in 1:(j-1)){
# Make sure the inputs are for the matrix "m" input1=rownames(m)[i] input2=colnames(m)[j] q=t[(t$Rec1==input1 & t$Rec2==input2),output] if(length(q)==0){ q=t[(t$Rec1==input2 & t$Rec2==input1),output] } m[i,j]=mean(q) m[j,i]=mean(q) m[j,j]=mean(q) }} I already created a 20x20 matrix "m" and have the rows and columns made up: m=matrix(data=NA, nrow=rl, ncol=rl, dimnames=list(R1=rec.list, R2=rec.list)) the length of a column in the matrix is 20 the length of n is 430 When I run this, the error: "Subscript is out of Bounds" appears when it reaches the m[i,j]. Checking again, the issue is primarily with "j" How would I go about fixing this issue (nevermind the "mean(q)", as I don't even know if that works and didn't get the chance to explore it)? [[alternative HTML version deleted]] ______________________________________________ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.