[R] how to save output all together

Chun-Ying Lee u9370004 at cc.kmu.edu.tw
Mon Dec 5 02:49:52 CET 2005


Dear R users:

I have a problem about catch the value from function.
I have following two functions (part):

sbolus1 <- function()
{
  .......
  for( i in 1:Subject)  {  
  kel<-par1
  Vd<-par2     
  PKindex<-sbolus1.out(PKtime,kel,Vd,defun,par1,par2,Dose,i)
  }   
  savefile(PKindex)      
}

sbolus1.out<-function(PKtime,kel,Vd,defun,par1,par2,Dose,i)
{
  time<-PKtime$time
  parms<-c(kel=kel,Vd=Vd) 
  C1.lsoda<-data.frame(lsoda(Dose/Vd,c(0,time),defun,parms)) 
  cat("\n")
  sim<-matrix(c(kel,Vd,par1,par2),2,2)
  dimnames(sim)<-list(c("kel","Vd"),c("Value","Original"))
  show(sim)
  cat("\n\n<< Output >>\n\n")
good<-ifelse(C1.lsoda[2:(length(time)+1),2]<=0,0,C1.lsoda[2:(length(time)+1),2])
  PKindex<-data.frame(i,C1.lsoda[2:(length(time)+1),1],good)
  colnames(PKindex)<-list("Subject","time","conc")
  show(PKindex)
  x<-C1.lsoda[2:(length(time)+1),1]
  y<-good
  plotting.sim(i,x,y)
  return(PKindex)
}

In each loop, it can generate one PKindex(consisting of subject , time and
concentration), and I want to save all the PKindex together. But in the
command I wrote, I just can save the last one. For example, if i=2, I just
save the data of subject 2. Please give me some comments about the problem.
Thanks in agvance !!




More information about the R-help mailing list