Here is the code for a matrix that I am trying to construct:
Data3 = read.csv(filename, stringsAsFactors = FALSE)
Data3
v <- LETTERS[1:10]
A <- matrix(0, nrow = nrow(Data3),ncol = 5)
A
A[cbind(1:nrow(Data3),match(Data3$AwayTeam,v))] <- 1
A[cbind(1:nrow(Data3),match(Data3$HomeTeam,v))] <- -1
A
Essentially, it will be a 20x10 matrix, where every "away team" will be denoted by a "1" and every home team will be a "-1."
This bit of code has worked fine every other time I have used it, but for some reason now I am met with the "subscript out of bounds" error. Any ideas on how to fix this?