On 13-03-03 3:39 PM, Oleguer Plana Ripoll wrote:
Dear Milan and other users,

Thank you for your help, it worked. The problem is that the function "do.call" 
is not ready for vectors and I need it in order to integrate it afterwards.

do.call() is fine, it's the argument list that needs fixing. Construct a list containing elements q, shape, and scale.


With the pweibull, I can write:
pweibull(1,shape=1)
pweibull(2,shape=1)
pweibull(1:2,shape=1)

When I do the same with the do.call, I obtain an error:
do.call("pweibull",c(q=1,list(shape=1,scale=1)))
do.call("pweibull",c(q=2,list(shape=1,scale=1)))
do.call("pweibull",c(q=1:2,list(shape=1,scale=1)))
Error in pweibull(q1 = 1L, q2 = 2L, shape = 1, scale = 1) :
   unused argument(s) (q1 = 1, q2 = 2)

Do you know how can I solve it?

parameters <- list(shape=1, scale=1)
do.call("pweibull", c(list(q=1:2), parameters))

Duncan Murdoch


Thank you,
Oleguer


On 03/03/2013, at 20:32, Milan Bouchet-Valat <nalimi...@club.fr> wrote:

Le dimanche 03 mars 2013 à 19:49 +0100, Oleguer Plana Ripoll a écrit :
Hello everyone,

I have a quick question but I am stuck with it and I do not know how
to solve it.

Imagine I need the distribution function of a Weibull(1,1) at t=3,
then I will write pweibull(3,1,1).

I want to keep the shape and scale parameters in a list (or a vector
or whatever). Then I have
parameters<-list(shape=1,scale=1)
but when I write pweibull(3,parameters) I get the following error:
Error in pweibull(q, shape, scale, lower.tail, log.p) :
  Non-numeric argument to mathematical function

I have to write pweibull(3,parameters[[1]],parameters[[2]]) but I am
very interested in being able to write pweibull(3,parameters).

Does anyone know how to solve it?
What you are looking for is do.call():

parameters <- list(q=3, shape=1, scale=1)
do.call("pweibull", parameters)

or

parameters <- list(shape=1, scale=1)
do.call("pweibull", c(q=3, parameters))


Regards

Thank you very much,

Oleguer Plana
        [[alternative HTML version deleted]]

______________________________________________
R-help@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.



        [[alternative HTML version deleted]]



______________________________________________
R-help@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.


______________________________________________
R-help@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.

Reply via email to