Skip to content
Prev 264058 / 398502 Next

plotting survival curves with model parameters

On Jun 28, 2011, at 5:46 PM, Trey Batey wrote:

            
I modified your function to have named parameters:
cbind outputs a matrix and the presence of character values means all  
your numbers are now character.... bad programming practice. Fix is  
here:

 > sil.anthro[, 2:6] <- sapply(sil.anthro[, 2:6], function(x)  
as.numeric(as.character(x)) )
 > str(sil.anthro)
'data.frame':	2 obs. of  6 variables:
  $ names: Factor w/ 2 levels "Ache","Hadza": 2 1
  $ a1   : num  0.351 0.157
  $ b1   : num  0.895 0.721
  $ a2   : num  0.011 0.013
  $ a3   : num  6.7e-06 4.8e-05
  $ b3   : num  0.125 0.103

 > with( sil.anthro[1, -1], siler(a1=a1,b1=b1,a2=a2,a3=a3,b3=b3) )
 > with( sil.anthro[2, -1], siler(a1=a1,b1=b1,a2=a2,a3=a3,b3=b3) )

Seems to work.

-- 
David.
Could use names as index
with( sil.anthro[sil.anthro$names=="Hadza", ],
                 siler(a1=a1,b1=b1,a2=a2,a3=a3,b3=b3) )