[R] Help for a function

Jeremy Miles jeremy.miles at gmail.com
Tue Dec 4 18:09:46 CET 2012


What are you expecting?

What do you get?

What is the problem?

J

On 4 December 2012 06:01, anoumou <teko_maurice at yahoo.fr> wrote:
> Hello all,
> I need a help.
> I am modeling a disease and a create a R function like that:
>
> Lambda<-function (x,date1,r,h,a){
>   ndate1 <- as.Date(date1, "%d/%m/%Y")
>   t1 <- as.numeric(ndate1)
>   x[order(x$i),]
>   t <-x[,"t"]
>   i <-x[,"i"]
>   CONTAGIEUX <-x[,"CONTAGIEUX"]
>   while ( t1 < min(t) ){
>   for (i in 1:length(i) ){
>     {for (j in 1:CONTAGIEUX[length(CONTAGIEUX)]){
>       res1[j] <-(a*h)
>       res2 <-sum( res1[j])
>     }
>      }
>   lambda[i] <- r*res2
>   }
>   }
> x<-data.frame(x,lambda)
> x
> }
>
> on such data :
>
>         DATE    i       Symptomes       t       Incubation      CONTAGIEUX
> 1       2009-04-29       Canada         13      14363   13      13
> 2       2009-05-01       Israel         2       14365   2       2
> 3       2009-05-09      argentina       1       14373   1       1
> 5       2009-05-09      australia       1       14373   1       1
> 6       2009-05-10      australia       1       14374   2       2
> 7       2009-04-29      Austria         1       14363   1       1
> 8       2009-04-30      Austria         1       14364   2       2
> 9       2009-05-01      Austria         1       14365   2       3
> 10      2009-05-02      Austria         1       14366   2       4
> 11      2009-05-03      Austria         1       14367   2       5
> 17      2009-05-09      Austria         1       14373   2       7
> 18      2009-05-10      Austria         1       14374   2       7
> 19      2009-05-08      brasil  4       14372   4       4
> 20      2009-05-09      brazil  6       14373   6       6
> 21      2009-05-10      brazil  6       14374   12      12
> 22      2009-05-02      canada  51      14366   51      51
> 23      2009-05-03      canada  85      14367   136     136
> 24      2009-05-04      canada  101     14368   186     237
> 31      2009-04-27      Canada  6       14361   6       6
> 32      2009-04-28      Canada  6       14362   6       6
> 33      2009-04-30      Canada  19      14364   25      25
> 34      2009-05-01      Canada  34      14365   53      59
> 35      2009-05-01      China,HongKong, SAR     1       14365   1       1
> 36      2009-05-02      China,HongKong, SAR     1       14366   2       2
> 37      2009-05-03      China,HongKong, SAR     1       14367   2       3
> 38      2009-05-04      China,HongKong, SAR     1       14368   2       4
> 44      2009-05-10      China,HongKong, SAR     1       14374   2       7
> 45      2009-05-04      colombia        1       14368   1       1
> 46      2009-05-05      colombia        1       14369   2       2
> 47      2009-05-06      colombia
>
> But i do not get the results,i try by all means but i d'ont understant the
> problem.
> Thanks for your help.
>
>
>
> --
> View this message in context: http://r.789695.n4.nabble.com/Help-for-a-function-tp4652054.html
> Sent from the R help mailing list archive at Nabble.com.
>
> ______________________________________________
> 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.




More information about the R-help mailing list