[Rd] Need to tell R CMD check that a function qr.R is not a method

2012-09-07 Thread Tim Hesterberg
When creating a package, I would like a way to tell R that
a function with a period in its name is not a method.

I'm writing a package now with a modified version of qr.R.
R CMD check gives warnings:

* checking S3 generic/method consistency ... WARNING
qr:
  function(x, ...)
qr.R:
  function(qr, complete, pivot)

See section ‘Generic functions and methods’ of the ‘Writing R
Extensions’ manual.

* checking Rd \usage sections ... NOTE
S3 methods shown with full name in documentation object 'QR.Auxiliaries':
  ‘qr.R’

The \usage entries for S3 methods should use the \method markup and
not their full name.
See the chapter ‘Writing R documentation files’ in the ‘Writing R
Extensions’ manual.

[[alternative HTML version deleted]]

__
R-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel


[Rd] Suggest adding a 'pivot' argument to qr.R

2012-09-07 Thread Tim Hesterberg
I suggest adding a 'pivot' argument to qr.R, to obtain columns in the
same order as the original x, so that
  a <- qr(x)
  qr.Q(a) %*% qr.R(a, pivot=TRUE)
returns x.

--
#  File src/library/base/R/qr.R

qr.R <- function(qr, complete = FALSE, pivot = FALSE)
{
  # Args:
  #   qr: a QR decomposition, produced by qr()
  #   complete: logical, if TRUE then return all columns
  #   pivot: logical, if TRUE then columns of the result are permuted to
  #be in the same order as the original x.
  if (!is.qr(qr))
stop("argument is not a QR decomposition")
  R <- qr$qr
  if (!complete)
R <- R[seq.int(min(dim(R))), , drop = FALSE]
  R[row(R) > col(R)] <- 0
  if(pivot)
R <- R[, order(qr$pivot)]
  R
}


--
% File src/library/base/man/qraux.Rd

qr.R(qr, complete = FALSE, pivot = FALSE)

\item{pivot}{logical expression of length 1.  If \code{TRUE},
  then columns of the result are permuted to be in the same order
  as the original \code{x}.}

zapsmall(qr.R(a))   # columns are int b1 c1 c2 b2 c3
zapsmall(qr.R(a, pivot = TRUE)) # columns are int b1 b2 c1 c2 c3

[[alternative HTML version deleted]]

__
R-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel


Re: [Rd] Need to tell R CMD check that a function qr.R is not a method

2012-09-07 Thread Uwe Ligges



On 07.09.2012 17:05, Tim Hesterberg wrote:

When creating a package, I would like a way to tell R that
a function with a period in its name is not a method.


You can't. There are few exception for historic names (S definitions) 
hardcoded in R.


Best,
Uwe





I'm writing a package now with a modified version of qr.R.
R CMD check gives warnings:

* checking S3 generic/method consistency ... WARNING
qr:
   function(x, ...)
qr.R:
   function(qr, complete, pivot)

See section ‘Generic functions and methods’ of the ‘Writing R
Extensions’ manual.

* checking Rd \usage sections ... NOTE
S3 methods shown with full name in documentation object 'QR.Auxiliaries':
   ‘qr.R’

The \usage entries for S3 methods should use the \method markup and
not their full name.
See the chapter ‘Writing R documentation files’ in the ‘Writing R
Extensions’ manual.

[[alternative HTML version deleted]]



__
R-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel



__
R-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel


Re: [Rd] Need to tell R CMD check that a function qr.R is not a method

2012-09-07 Thread Warnes, Gregory

On 9/7/12 12:55 PM, "Uwe Ligges"  wrote:

>On 07.09.2012 17:05, Tim Hesterberg wrote:
>> When creating a package, I would like a way to tell R that
>> a function with a period in its name is not a method.
>
>You can't. There are few exception for historic names (S definitions)
>hardcoded in R.
>

Would it be possible to add a \notmethod{} decorator to allow package
maintainers to avoid these messages?


-Greg

__
R-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel


Re: [Rd] Need to tell R CMD check that a function qr.R is not a method

2012-09-07 Thread Henrik Bengtsson
Would a workaround (for pleasing R CMD check) be to do:

qr.R <- function(...) UseMethod("qr.R", ...)

qr.R.qr <- function(qr, complete, pivot) {
  # No need to assert the class of 'qr' here.
  ...
}

Haven't tried it.  Method dispatching may also add unnecessary
overhead if called lots of times.

/Henrik


On Fri, Sep 7, 2012 at 9:55 AM, Uwe Ligges
 wrote:
>
>
> On 07.09.2012 17:05, Tim Hesterberg wrote:
>>
>> When creating a package, I would like a way to tell R that
>> a function with a period in its name is not a method.
>
>
> You can't. There are few exception for historic names (S definitions)
> hardcoded in R.
>
> Best,
> Uwe
>
>
>
>>
>> I'm writing a package now with a modified version of qr.R.
>> R CMD check gives warnings:
>>
>> * checking S3 generic/method consistency ... WARNING
>> qr:
>>function(x, ...)
>> qr.R:
>>function(qr, complete, pivot)
>>
>> See section ‘Generic functions and methods’ of the ‘Writing R
>> Extensions’ manual.
>>
>> * checking Rd \usage sections ... NOTE
>> S3 methods shown with full name in documentation object 'QR.Auxiliaries':
>>‘qr.R’
>>
>> The \usage entries for S3 methods should use the \method markup and
>> not their full name.
>> See the chapter ‘Writing R documentation files’ in the ‘Writing R
>> Extensions’ manual.
>>
>> [[alternative HTML version deleted]]
>>
>>
>>
>> __
>> R-devel@r-project.org mailing list
>> https://stat.ethz.ch/mailman/listinfo/r-devel
>>
>
> __
> R-devel@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-devel

__
R-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel


Re: [Rd] Need to tell R CMD check that a function qr.R is not a method

2012-09-07 Thread Simon Urbanek
On Sep 7, 2012, at 12:59 PM, "Warnes, Gregory"  
wrote:

> 
> On 9/7/12 12:55 PM, "Uwe Ligges"  wrote:
> 
>> On 07.09.2012 17:05, Tim Hesterberg wrote:
>>> When creating a package, I would like a way to tell R that
>>> a function with a period in its name is not a method.
>> 
>> You can't. There are few exception for historic names (S definitions)
>> hardcoded in R.
>> 
> 
> Would it be possible to add a \notmethod{} decorator to allow package 
> maintainers to avoid these messages?
> 

I would strongly support any solution since it has bitten me as well...

__
R-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel


Re: [Rd] Need to tell R CMD check that a function qr.R is not a method

2012-09-07 Thread Duncan Murdoch

On 07/09/2012 2:00 PM, Simon Urbanek wrote:

On Sep 7, 2012, at 12:59 PM, "Warnes, Gregory"  
wrote:

>
> On 9/7/12 12:55 PM, "Uwe Ligges"  wrote:
>
>> On 07.09.2012 17:05, Tim Hesterberg wrote:
>>> When creating a package, I would like a way to tell R that
>>> a function with a period in its name is not a method.
>>
>> You can't. There are few exception for historic names (S definitions)
>> hardcoded in R.
>>
>
> Would it be possible to add a \notmethod{} decorator to allow package 
maintainers to avoid these messages?
>

I would strongly support any solution since it has bitten me as well...


An alternative would be to say that if it's not declared to be a method 
in the NAMESPACE file, it's not one.  I think that would actually be 
more work though, since it would probably break a lot of packages...


Duncan Murdoch

__
R-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel


Re: [Rd] Need to tell R CMD check that a function qr.R is not a method

2012-09-07 Thread Simon Urbanek
On Sep 7, 2012, at 2:14 PM, Duncan Murdoch  wrote:

> On 07/09/2012 2:00 PM, Simon Urbanek wrote:
>> On Sep 7, 2012, at 12:59 PM, "Warnes, Gregory"  
>> wrote:
>> 
>> >
>> > On 9/7/12 12:55 PM, "Uwe Ligges"  wrote:
>> >
>> >> On 07.09.2012 17:05, Tim Hesterberg wrote:
>> >>> When creating a package, I would like a way to tell R that
>> >>> a function with a period in its name is not a method.
>> >>
>> >> You can't. There are few exception for historic names (S definitions)
>> >> hardcoded in R.
>> >>
>> >
>> > Would it be possible to add a \notmethod{} decorator to allow package 
>> > maintainers to avoid these messages?
>> >
>> 
>> I would strongly support any solution since it has bitten me as well...
> 
> An alternative would be to say that if it's not declared to be a method in 
> the NAMESPACE file, it's not one.

Yes, that's what I was expecting in the first place ...

(BTW: \function{} may be more natural than \notmethod{})


>  I think that would actually be more work though, since it would probably 
> break a lot of packages...
> 

I wonder - those would already get a warning that they don't declare S3 methods 
properly so it may not be as surprising. Moreover it won't actually break 
anything at this point, just silence some warnings (unless we get to 
distinguish S3 methods from functions in S3 dispatch, but I last time I was 
told we are not anywhere close to a solution on that one ...).

__
R-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel


Re: [Rd] Suggest adding a 'pivot' argument to qr.R

2012-09-07 Thread peter dalgaard

On Sep 7, 2012, at 17:16 , Tim Hesterberg wrote:

> I suggest adding a 'pivot' argument to qr.R, to obtain columns in the
> same order as the original x, so that
>  a <- qr(x)
>  qr.Q(a) %*% qr.R(a, pivot=TRUE)
> returns x.

That would come spiraling down in flames the first time someone tried to use 
backsolve on it, wouldn't it? I mean, a major point of QR is that R is 
triangular; doesn't make much sense to permute the columns without retaining 
the pivoting permutation. 

-- 
Peter Dalgaard, Professor,
Center for Statistics, Copenhagen Business School
Solbjerg Plads 3, 2000 Frederiksberg, Denmark
Phone: (+45)38153501
Email: pd@cbs.dk  Priv: pda...@gmail.com

__
R-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel