[R] distribution functions and lists
Milan Bouchet-Valat
nalimilan at club.fr
Sun Mar 3 20:32:26 CET 2013
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 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