[R] optimize
peter dalgaard
pdalgd at gmail.com
Thu Oct 2 01:03:07 CEST 2014
Yup. And books don't rewrite themselves when the software changes, so if things don't seem to work, check the _current_ documentation.
-pd
On 01 Oct 2014, at 21:53 , William Dunlap <wdunlap at tibco.com> wrote:
> 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.
>
> ______________________________________________
> 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.
--
Peter Dalgaard, Professor,
Center for Statistics, Copenhagen Business School
Solbjerg Plads 3, 2000 Frederiksberg, Denmark
Phone: (+45)38153501
Email: pd.mes at cbs.dk Priv: PDalgd at gmail.com
More information about the R-help
mailing list