Why is the following code producing this error?

ct=as.matrix(rbind( c(9,44,13,10), c(11,52,23,22), c(9,41,12,27))) rownames(ct) = c("low","middle","high") colnames(ct) = c("some hs", "hs grad", "some college", "college grad") ct msq.test=function(ct, row.scores, col.scores) { ... show more ct=as.matrix(rbind(
c(9,44,13,10),
c(11,52,23,22),
c(9,41,12,27)))

rownames(ct) = c("low","middle","high")
colnames(ct) = c("some hs", "hs grad", "some college", "college grad")
ct

msq.test=function(ct, row.scores, col.scores)
{
x=rep(row.scores, apply(ct, 1, sum))
y=NULL
for(k in 1:(dim(ct)[1]))
{
y = c(y, rep(col.scores, ct[k,]) )
}
}

test.out=msq.test(ct, row.scores=c(1,2,3,4), col.scores=c(0,2,4,6))
test.out
cbind(test.out$x, test.out$y)


error: Error in rep(row.scores, apply(ct, 1, sum)) : invalid times argument