[R] optimize
William Dunlap
wdunlap at tibco.com
Wed Oct 1 21:53:58 CEST 2014
Change your 'max=T' to 'maximum=TRUE'. A long time ago the '...' in
optimize's argument
list was at the end, so you could abbreviate any of its argument
names. Now the '...' is the
third formal argument, so all the trailing arguments meant for
optimize itself must be fully
spelled out. Otherwise they get passed to f(), which is the cause of
your error message.
(The T->TRUE is an independent issue - you may make a variable called
'T' that does not
have the value TRUE, but you cannot mask TRUE. TRUE is a literal
value, like 123, not a
variable.)
Bill Dunlap
TIBCO Software
wdunlap tibco.com
On Wed, Oct 1, 2014 at 11:20 AM, Nick gayeski
<nick at wildfishconservancy.org> wrote:
> Page 53 of Robert and Casella's "Use R" book, Introduction to Monte Carlo
> Methods with R, has the following code:
>
>
>
> optimize(f=function(x){dbeta(x,2.7,6.3)},
>
> + interval=c(0,1) ,max=T)$objective
>
>
>
> This should return
>
> [1] 2.669744
>
>
>
> I run R from R Studio. When I enter this code I receive the following error
> message: Error in f(arg, ...) : unused argument (max = TRUE)
>
>
>
> Can someone help me understand why I get this error?
>
>
>
> Thanks.
>
>
>
> NickG
>
>
> [[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