See the corrections in your first function!
Hope it helps,
Ales Ziberna
----- Original Message -----
From: "Chun-Ying Lee" <u9370004 at cc.kmu.edu.tw>
To: <r-help at stat.math.ethz.ch>
Sent: Monday, December 05, 2005 2:49 AM
Subject: [R] how to save output all together
Dear R users:
I have a problem about catch the value from function.
I have following two functions (part):
sbolus1 <- function()
{
.......
PKindex<-<-vector(Subject,mode="list")
#creates a list to save outputs of individual calls to your function
for( i in 1:Subject) {
kel<-par1
Vd<-par2
PKindex[[i]]<-sbolus1.out(PKtime,kel,Vd,defun,par1,par2,Dose,i)
#saves an output of the current call to the function in an apporapriate
place in the list
}
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 !!
--------------------------------------------------------------------------------
______________________________________________
R-help at stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide!
http://www.R-project.org/posting-guide.html