From r.hankin at noc.soton.ac.uk  Thu Jul 12 10:47:44 2007
From: r.hankin at noc.soton.ac.uk (Robin Hankin)
Date: Thu, 12 Jul 2007 09:47:44 +0100
Subject: [Rd] sweep sanity checking?
In-Reply-To: <20070712081616.GA7100@cs.cas.cz>
References: <468579C0.7090809@zoo.ufl.edu>
	<loom.20070709T175233-590@post.gmane.org>
	<469557AC.2010607@acm.org> <20070712081616.GA7100@cs.cas.cz>
Message-ID: <316C7A29-DB9F-4645-A4DF-275BA30E1855@noc.soton.ac.uk>

Hi

Brian Ripley, Heather Turner, and myself discussed this
issue at some length in a thread starting 20 June 2005 (how
do folk give a URL that points to a thread?).

The consensus was that adding a warning level option to sweep
was a good idea; Heather posted a version of sweep that implemented
this, which she posted on 21 June 2005.


rksh




On 12 Jul 2007, at 09:16, Petr Savicky wrote:

> The suggestion sounds reasonable to me. Let me add that sweep is  
> written
> to work even if MARGIN includes more than one dimension. To handle  
> these
> cases correctly, the test may be replaced e.g. by
>      if (check.margin && prod(dims[MARGIN])!=length(STATS)) {
>        warning("length(STATS) != prod(dim(x)[MARGIN])")
>      } else if (prod(dims[MARGIN]) %% length(STATS)!=0)
>        warning("prod(dim(x)[MARGIN]) is not a multiple of length 
> (STATS)")
> or even by
>      dimstat <- if (is.null(dim(STATS))) length(STATS) else dim(STATS)
>      if (check.margin && any(dims[MARGIN]!=dimstat)) {
>        warning("length(STATS) or dim(STAT) do not match dim(x) 
> [MARGIN]")
>      } else if (prod(dims[MARGIN]) %% length(STATS)!=0)
>        warning("prod(dim(x)[MARGIN]) is not a multiple of length 
> (STATS)")
>
> Petr.
>
>> Just an opinion from an R user: I think it's a sound idea.  I use  
>> my own
>> version of sweep with a stricter check: it stops if the vector is not
>> exactly the right length.
>>
>> -- Tony Plate
>>
>> Ben Bolker wrote:
>>> Ben Bolker <bolker <at> zoo.ufl.edu> writes:
>>>
>>>
>>>>   What would R-core think of the following 'enhanced'
>>>> sweep?
>>>>
>>>
>>>  (now posted at
>>> http://wiki.r-project.org/rwiki/doku.php?id=rdoc:base:sweep
>>> )
>>>
>>> It always warns if dim(x)[MARGIN] is
>>>
>
> ______________________________________________
> R-devel at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-devel

--
Robin Hankin
Uncertainty Analyst
National Oceanography Centre, Southampton
European Way, Southampton SO14 3ZH, UK
  tel  023-8059-7743



[Rd] sweep sanity checking?
Robin Hankin