[R] multiplicate 2 functions

Uwe Ligges ligges at statistik.uni-dortmund.de
Fri Jul 22 17:24:11 CEST 2005


No, does not work that way. And I still do not know what you are finally 
going to achieve. You want to integrate over beta18, but use a set of 10 
density values at the same time? I am really confused.

Anyway, if you do not know beta18, you can onl write a function that 
depends on such an argument, but you cannot call that function without 
specifying that argument - it simply cannot be evaluated.

I guess you are looking for software that does symbolic algebra. R 
cannot (well, almost), R is mainly intended for numerical computations.

Uwe Ligges




herodote at oreka.com wrote:

> Thks for your answer,
> here is an exemple of what i do with the errors in french...
> 
>>tmp
> 
> [1] 200 150 245 125 134 345 320 450 678
> 
>>beta18
> 
> Erreur : Objet "beta18" not found //NORMAL just to show it
> 
>>eta
> 
> [1] 500
> 
>>func1<-function(beta18) dweibull(tmp[1],beta18,eta)
> 
> 
>>func1<-func1(beta18) * function(beta18)
> 
> dweibull(tmp[2],beta18,eta)
> 
> Erreur dans dweibull(tmp[1], beta18, eta) : Objet "beta18"
> not found 
> //I don't want to evaluate weibull immediatly just want to
> initialize the function then integrate on beta18,i have to
> make the multiplication of weibull at each time pointed by
> tmp then integrate it to obtain a norm.
> 
> 
>>func1<-func1() * function(beta18) dweibull(tmp[2],beta18,eta)
> 
> 
> Erreur dans dweibull(tmp[1], beta18, eta) : l'argument
> "beta18" est manquant, avec aucune valeur par défaut
> 
> 
>>func1<-func1 * function(beta18) dweibull(tmp[2],beta18,eta)
> 
> 
> Erreur dans func1 * function(beta18) dweibull(tmp[2],
> beta18, eta) :
> argument non numérique pour un opérateur binaire
> 
> 
>>func1<-func1 & function(beta18) dweibull(tmp[2],beta18,eta)
> 
> 
> Erreur dans func1 & function(beta18) dweibull(tmp[2],
> beta18, eta) :
> ces opérations ne sont possibles que pour des types
> numériques ou logiques
> 
> 
>>func1<-func1(beta18) & function(beta18)
> 
> dweibull(tmp[2],beta18,eta)
> 
> Erreur dans dweibull(tmp[1], beta18, eta) : Objet "beta18"
> non trouvé
> 
> I hope you understand what i want to do.
> 
> thks
> guillaume
> ---------- Initial Header -----------
> 
>>From : Uwe Ligges <ligges at statistik.uni-dortmund.de>
> To : "herodote at oreka.com" <herodote at oreka.com>
> Cc : r-help <r-help at stat.math.ethz.ch>
> Date : Fri, 22 Jul 2005 12:51:47 +0200
> Subject : Re: [R] Generate a function
> 
> herodote at oreka.com wrote:
> 
> 
>>hi all,
>>
>>I need to generate a function inside a loop:
>>
>>tmp is an array
> 
> 
> Well, a 1-d array, or better say a vector of length 10,
> given the code 
> below is correct.
> 
> 
> 
>>for (i in 1:10)
>>{
>>func<- func * function(beta1) dweibull(tmp[i],beta1,eta)
>>}
>>
>>because then i need to integrate this function on beta.
>>
>>I could have written this :
>>
>>func<-function(beta1) prod(dweibull(tmp,beta1,eta)) (with
> 
> eta and beta1 set)
> 
>>but it is unplottable and no integrable... i could make it
> 
> a bit different but if i do that ( prod(tmp)=~Inf ) i'm stuck.
> 
>>
>>I've looked in R-poetry and i didn't find anything usefull.
>>
>>I think i have a problem with how i tell R my function is,
> 
> R seems to think it is a function like programmers do but
> not a f(x) function.
> 
> Please specify a reproducible example (as the posting guide
> asks to do), 
> that means including the values for tmp, beta1 and eta.
> Then we might be able to explain where you have your problems.
> 
> Uwe Ligges
> 
> 
>>Thks 
>>guillaume
>>
>>////////////////////////////////////////////////////////////
>>// Webmail Oreka : http://www.oreka.com
>>////////////////////////////////////////////////////////////
>>
>>______________________________________________
>>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
> 
> 
> 
> ////////////////////////////////////////////////////////////
> // Webmail Oreka : http://www.oreka.com
> ////////////////////////////////////////////////////////////
> 
> 
> ////////////////////////////////////////////////////////////
> // Webmail Oreka : http://www.oreka.com
> ////////////////////////////////////////////////////////////
> 
> ______________________________________________
> 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




More information about the R-help mailing list