Vidhu Choudhary
2008-May-20 15:19 UTC
[R] Error in `[.matrix.coo`(x, rw, cl) : Subscripts out of bound
Hi All, I am facing a strange problem. I am making a R Package that internally run various packages and summarizes the results from them. I am getting this error from the piece of code written below. The text in red color is throwing Error in `[.matrix.coo`(x, rw, cl) : Subscripts out of bound Value of m is 99 This code works fine when I tested it. But money I make library it gives me error. I have attached the file names messages.txt which contains the warnings/messages generated while making R package. I am out of ideas Kindly suggest something regards vidhu ############################################################################ `sm.quantreg` <- function(y, lambda = 1.0, tau = 0.5, interpolate = FALSE) { nona <- !is.na(y) ## Sparse matrices: E, D, and B if(!interpolate) { y.nona <- y[nona] m <- length(y.nona) *1.0 E <- as.matrix.csr(0,m,m) diag(E) <- 1 * D <- diff(E)* B <- rbind(E, lambda * D) ystar <- c(y.nona, rep(0,m-1)) }else { ## interpolate missing values via weighting y[!nona] <- 0 m <- length(y) *1.0 E <- as.matrix.csr(0,m,m) diag(E) <- 1 D <- diff(E) tmp <- as.matrix.csr(0,m,m) diag(tmp) <- as.numeric(nona) B <- rbind(tmp, lambda * D) ystar <- c(y, rep(0,m-1)) } ## use sparse matrices and accompanying mathematical operations cat ("before try\n") try(myrq <- rq.fit.sfn(as.matrix.csr(B), ystar, tau)) cat ("after try\n") if(exists("myrq")) { if(!interpolate) { ys <- rep(NA, length(y)) ys[nona] <- myrq$coef }else { ys <- myrq$coef } }else { cat("Error triggered within Quantreg algorithm!\n") ys <- NULL } return(ys) } ########################## -------------- next part -------------- An embedded and charset-unspecified text was scrubbed... Name: messages.txt URL: <https://stat.ethz.ch/pipermail/r-help/attachments/20080520/0e63a0f9/attachment.txt>