[R] help with my sloppy syntax
Charles Annis, P.E.
Charles.Annis at StatisticalEngineering.com
Thu Aug 14 18:18:05 CEST 2008
Professor Ripley:
Not quite. Here is what works, followed by what doesn't:
What works:
> par <- NIM.results$par
> list(par[1], par[2], par[3], par[4], par[5], a.hat.decision,
noise.threshold, a.hat.vs.a.data)
[[1]]
[1] 16.91573
[[2]]
[1] 0.9176942
[[3]]
[1] 1.715070
[[4]]
[1] 39.69884
[[5]]
[1] 2.037159
[[6]]
[1] 50
[[7]]
[1] 50
[[8]]
size a.hat
1 10.0 37.34855
2 10.8 45.43194 and the list continues for 101 elements
###############
What doesn't work: (notice the difference in structure for the first 5
elements)
> list(as.list(NIM.results$par), a.hat.decision, noise.threshold, signal.Y,
noise.Y, list(a.hat.vs.a.data))
[[1]]
[[1]][[1]]
[1] 16.91573
[[1]][[2]]
[1] 0.9176942
[[1]][[3]]
[1] 1.715070
[[1]][[4]]
[1] 39.69884
[[1]][[5]]
[1] 2.037159
[[2]]
[1] 50
[[3]]
[1] 50
[[4]]
[1] 60
[[5]]
[1] 40
[[6]]
[[6]][[1]]
size a.hat
1 10.0 37.34855
2 10.8 45.43194
###
The first works with my do.call; the second balks with this result:
do.call("Draw.NIM.POD.curve", list(as.list(NIM.results$par), a.hat.decision,
noise.threshold, signal.Y, noise.Y, list(a.hat.vs.a.data)))
Error in a.hat.decision - b0 : non-numeric argument to binary operator
>
Thank you for your counsel.
Charles Annis, P.E.
Charles.Annis at StatisticalEngineering.com
phone: 561-352-9699
eFax: 614-455-3265
http://www.StatisticalEngineering.com
-----Original Message-----
From: r-help-bounces at r-project.org [mailto:r-help-bounces at r-project.org] On
Behalf Of Prof Brian Ripley
Sent: Thursday, August 14, 2008 11:48 AM
To: Charles Annis, P.E.
Cc: r-help at r-project.org; annisc at asme.org
Subject: Re: [R] help with my sloppy syntax
On Thu, 14 Aug 2008, Charles Annis, P.E. wrote:
> Thank you Professor Ripley:
>
>> From your response it is clear that I left out something important, for
> which I apologize.
>
> Part of the et cetera is another list. Your method, which would work
> otherwise, also converts the other list to its members. The program being
> called has an argument list like (a, b, c, d, e, w, x, y, z) where z is a
> list but the other elements are single variables (not lists or vectors).
Does using list(z) inside c() work? If I understand you correctly it
will.
> I have the values of (a, b, c, d, e) returned from the R function "optim"
as
> results$par. I wish to call my function with those values, some others,
and
> finally with that other list, z.
>
> Is there a way to do this without defining another variable "var" and
> listing its elements without the undesirable unlisting that terminal
> variable z?
>
> Thank you.
>
> Charles Annis, P.E.
>
> Charles.Annis at StatisticalEngineering.com
> phone: 561-352-9699
> eFax: 614-455-3265
> http://www.StatisticalEngineering.com
>
>
> -----Original Message-----
> From: r-help-bounces at r-project.org [mailto:r-help-bounces at r-project.org]
On
> Behalf Of Prof Brian Ripley
> Sent: Thursday, August 14, 2008 11:20 AM
> To: Charles Annis, P.E.
> Cc: r-help at r-project.org; annisc at asme.org
> Subject: Re: [R] help with my sloppy syntax
>
> Try c(as.list(par), a.hat.decision, .... et cetera ...)
>
> We are guessing what any of these are, of course.
>
> On Thu, 14 Aug 2008, Charles Annis, P.E. wrote:
>
>> R-ians:
>>
>> After some effort I coerced my code to do what I want but my syntax is a
>> kludge. Suggestions on more elegant syntax?
>>
>> par <- NIM.results$par
>> do.call("Draw.NIM.POD.curve", list(par[1], par[2], par[3], par[4],
>> par[5], a.hat.decision, .... et cetera ...
>>
>> It seems that I should be able to avoid defining the variable "par" and
> then
>> specifying each of its elements, but all my attempts resulted in a list
>> whose first element is a list, rather than the elements of the list. And
> my
>> attempts at unlist were unsuccessful.
>>
>> Thank you.
>>
>> Charles Annis, P.E.
>>
>> Charles.Annis at StatisticalEngineering.com
>> phone: 561-352-9699
>> eFax: 614-455-3265
>> http://www.StatisticalEngineering.com
>
> --
> Brian D. Ripley, ripley at stats.ox.ac.uk
> Professor of Applied Statistics, http://www.stats.ox.ac.uk/~ripley/
> University of Oxford, Tel: +44 1865 272861 (self)
> 1 South Parks Road, +44 1865 272866 (PA)
> Oxford OX1 3TG, UK Fax: +44 1865 272595
>
>
--
Brian D. Ripley, ripley at stats.ox.ac.uk
Professor of Applied Statistics, http://www.stats.ox.ac.uk/~ripley/
University of Oxford, Tel: +44 1865 272861 (self)
1 South Parks Road, +44 1865 272866 (PA)
Oxford OX1 3TG, UK Fax: +44 1865 272595
More information about the R-help
mailing list