# NOT RUN {
# old message, do not loop, when you create a large sparse matrix
set.seed(13)
nz <- 128
ln <- nz^2
smat <- spam(0,ln,ln)
is <- sample(ln,nz)
js <- sample(ln,nz)
system.time(for (i in 1:nz) smat[is[i], js[i]] <- i)
system.time(smat[cbind(is,js)] <- 1:nz)
getClass("spam")
options(spam.NAOK=TRUE)
as.spam(c(1, NA))
# }
Run the code above in your browser using DataLab