[R] Error in `[.matrix.coo`(x, rw, cl) : Subscripts out of bound

From: Vidhu Choudhary <vidhu.choudhary_at_gmail.com>
Date: Tue, 20 May 2008 11:19:30 -0400


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)
}
##########################

______________________________________________

R-help_at_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.
Received on Tue 20 May 2008 - 16:33:55 GMT

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Tue 20 May 2008 - 17:30:42 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.

list of date sections of archive