[R-sig-dyn-mod] deSolve warning and error messages

Ogurtsova, Ekaterina Ogurtsova at demogr.mpg.de
Wed Feb 20 12:49:11 CET 2013


Thomas! Thanks! 
It works nicely =)

-----Original Message-----
From: r-sig-dynamic-models-bounces at r-project.org [mailto:r-sig-dynamic-models-bounces at r-project.org] On Behalf Of Thomas Petzoldt
Sent: Wednesday, February 20, 2013 11:57 AM
To: r-sig-dynamic-models at r-project.org
Subject: Re: [R-sig-dyn-mod] deSolve warning and error messages

Dear Ekaterina,

you are probably right, not all outputs can be suppressed with suppressWarnings and I will look at it as soon as possible.


For the moment, the following workaround may help.

Thomas


##--------------------------------------------------------------
library(deSolve)

lng   <- 100
times <- seq(1, 100, length=lng)

simpleFun<-function(t,y, parms=NULL){
   p   <- array(y, dim=c(2, 2))
   age <- 1:101
   tab<-cbind(
      -seq(0.1, 5, length=101),  seq(0.8, 0.1, length=101),
       seq(0.1, 5, length=101), -seq(0.8, 0.1, length=101)
   )
   i <- max(which(age <= t))
   q <- array(tab[i,], dim=c(2,2))
   vec<-c(p %*% q)
   list(vec)
}

runSilent <- function() {
   options(warn = -1)
   on.exit(options(warn = 0))
   capture.output(res <- lsoda(y=diag(2), times=times,
     func=simpleFun, parms=NULL, maxsteps=10))
   res
}

res <- runSilent()

res

_______________________________________________
R-sig-dynamic-models mailing list
R-sig-dynamic-models at r-project.org
https://stat.ethz.ch/mailman/listinfo/r-sig-dynamic-models

----------
This mail has been sent through the MPI for Demographic Research.  Should you receive a mail that is apparently from a MPI user without this text displayed, then the address has most likely been faked. If you are uncertain about the validity of this message, please check the mail header or ask your system administrator for assistance.



More information about the R-sig-dynamic-models mailing list