[Rd] Circumventing code/documentation mismatches ('R CMD check')

2011-07-04 Thread Johannes Graumann
Hello,

As prompted by B. Ripley (see below), I am transfering this over from R-User 
...

For a package I am writing a function that looks like

test <- function(Argument1=NA){
# Prerequisite testing
if(!(is.na(Argument1))){
if(!(is.character(Argument1))){
stop("Wrong class.")
}
}
# Function Body
cat("Hello World\n")
}

Documentation of this is straight forward:

...
\usage{test(Argument1=NA)}
...

However writing the function could be made more concise like so:

test2 <- function(Argument1=NA_character_){
# Prerequisite testing
if(!(is.character(Argument1))){
stop("Wrong class.")
}
# Function Body
cat("Hello World\n")
}

To prevent confusion I do not want to use 'NA_character_' in the user-
exposed documentation and using 

...
\usage{test2(Argument1=NA)}
...

leads to a warning reagrding a code/documentation mismatch.

Is there any way to prevent that?

Sincerely, Joh

Prof Brian Ripley wrote:

> On Mon, 4 Jul 2011, Johannes Graumann wrote:
> 
>> Hello,
>>
>> I'm writing a package am running 'R CMD check' on it.
>>
>> Is there any way to make 'R CMD check' not warn about a missmatch between
>> 'NA_character_' (in the function definition) and 'NA' (in the
>> documentation)?
> 
> Be consistent   Why do you want incorrect documentation of your
> package?  (It is not clear of the circumstances here: normally 1 vs 1L
> and similar are not reported if they are the only errors.)
> 
> And please do note the posting guide
> 
> - this is not really the correct list
> - you were asked to give an actual example with output.

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


[Rd] Incorporating single functions from other packages: rules and regulations?

2013-01-13 Thread Johannes Graumann
Hi,

In a little pkg I'm developing I am in need of the functionality provided by 
plotrix::listDepth.

I am loath of having the depend on and import the whole package just for 
that purpose.

What is an acceptable way of integrating this functionality into my own 
package? Just copying the function and referencing it in the documentation 
appropriately?

Thanks for any hints.

Sincerely, Joh

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


[Rd] Package Directory Hierarchy: Recursive inclusion of *.R possible?

2010-02-03 Thread Johannes Graumann
Hello,

I would like to organize the "R" directory in my home-grown package into 
sub-directories, but "R CMD --build" doesn't seem to find *.R files below 
the actual source directory. Is there any way around that?

Thanks, Joh

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


[Rd] Package Building and Name Space

2008-01-23 Thread Johannes Graumann
... sorry for reposting this in a more appropriate forum than r.general ...

Hello,

I just don't get this and would appreciate if someone could write a line or
two: I'm trying to build this package and it stops installing after I add
the following to the NAMESPACES file:

>importFrom(gsubfn,strapply)

The error during the package test is:

Error in MyPackage::MyFunction :
  package 'MyPackage' has no name space and is not on the search path
Calls:  ...  -> switch -> sys.source -> eval ->
eval -> ::
Execution halted

'MyFunction' contains 'strapply' from gsubfn.

Please tell me where I err.

Thanks, Joh

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


Re: [Rd] Package Building and Name Space

2008-01-24 Thread Johannes Graumann
On Wednesday 23 January 2008 17:25:38 Duncan Murdoch wrote:
> On 1/23/2008 11:11 AM, Johannes Graumann wrote:
> > ... sorry for reposting this in a more appropriate forum than r.general
> > ...
> >
> > Hello,
> >
> > I just don't get this and would appreciate if someone could write a line
> > or two: I'm trying to build this package and it stops installing after I
> > add
> >
> > the following to the NAMESPACES file:
> >>importFrom(gsubfn,strapply)
> >
> > The error during the package test is:
> >
> > Error in MyPackage::MyFunction :
> >   package 'MyPackage' has no name space and is not on the search path
> > Calls:  ...  -> switch -> sys.source -> eval ->
> > eval -> ::
> > Execution halted
> >
> > 'MyFunction' contains 'strapply' from gsubfn.
> >
> > Please tell me where I err.
>
> The file is called NAMESPACE, not NAMESPACES.

And that's what it's called here ... sorry for the typo above. The error 
remains the same.

Joh



signature.asc
Description: This is a digitally signed message part.
__
R-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel


Re: [Rd] Package Building and Name Space

2008-01-24 Thread Johannes Graumann
On Wednesday 23 January 2008 18:24:15 Duncan Murdoch wrote:
> On 1/23/2008 11:31 AM, Johannes Graumann wrote:
> > On Wednesday 23 January 2008 17:25:38 Duncan Murdoch wrote:
> >> On 1/23/2008 11:11 AM, Johannes Graumann wrote:
> >> > ... sorry for reposting this in a more appropriate forum than
> >> > r.general ...
> >> >
> >> > Hello,
> >> >
> >> > I just don't get this and would appreciate if someone could write a
> >> > line or two: I'm trying to build this package and it stops installing
> >> > after I add
> >> >
> >> > the following to the NAMESPACES file:
> >> >>importFrom(gsubfn,strapply)
> >> >
> >> > The error during the package test is:
> >> >
> >> > Error in MyPackage::MyFunction :
> >> >   package 'MyPackage' has no name space and is not on the search path
> >> > Calls:  ...  -> switch -> sys.source -> eval ->
> >> > eval -> ::
> >> > Execution halted
> >> >
> >> > 'MyFunction' contains 'strapply' from gsubfn.
> >> >
> >> > Please tell me where I err.
> >>
> >> The file is called NAMESPACE, not NAMESPACES.
> >
> > And that's what it's called here ... sorry for the typo above. The error
> > remains the same.
>
> With the obscuring you've done it's pretty hard to be sure, but I'd
> assume you have the expression MyPackage::MyFunction somewhere in your
> package, but MyPackage doesn't have a namespace.  In that case, you have
> to make sure it is attached via
>
> library(MyPackage)
>
> or
>
> require(MyPackage)
>
> before you can use the "::" operator.

But it's "mypackage" I'm trying to check ... can't attach that yet since I 
need to package and install it first ...

Joh


signature.asc
Description: This is a digitally signed message part.
__
R-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel


[Rd] R CMD check and postscript fonts

2008-01-24 Thread Johannes Graumann
Hello,
I came across this by using R cmd check - otherwise I would probably not have
noticed.
One of my functions does something like this:
# postscript()
# plot(1, xlim = c(0, 10), ylim = c(0, 4), type = "n", ann = FALSE, axes = 
FALSE)
# text(1:10, 2, c("a","b"), cex = seqcex, family="mono",font=2)

Which results in the error:
Error in text.default(1:10, 2, c("a", "b"), cex = seqcex, family = "mono",  : 
  family 'mono' not included in PostScript device

'mono' is perfectly fine for my x11 device and 
# postscriptFonts()$mono

gives me:
$family
[1] "Courier"

$metrics
[1] "Courier.afm" "Courier-Bold.afm"   
[3] "Courier-Oblique.afm" "Courier-BoldOblique.afm"
[5] "Symbol.afm" 

$encoding
[1] "default"

attr(,"class")
[1] "Type1Font"

That looks all right to me no? How to remedy this?

Thanks for your patience, Joh

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


[Rd] Plot definition for custom class

2008-01-24 Thread Johannes Graumann
Hi,

Is there any way to trick R CMD check into not throwing this error after I
created a dedicated "plot" incarnation for my custom function?

* checking S3 generic/method consistency ... WARNING
plot:
  function(x, ...)
plot.MQUSpecMatch:
  function(x, mozlabel, labelcex)

Thanks again, Joh

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


Re: [Rd] R CMD check and postscript fonts

2008-01-24 Thread Johannes Graumann
Prof Brian Ripley  stats.ox.ac.uk> writes:

> 
> On Thu, 24 Jan 2008, Johannes Graumann wrote:
> 
> > Hello,
> > I came across this by using R cmd check - otherwise I would probably not 
> > have
> > noticed.
> > One of my functions does something like this:
> > # postscript()
> > # plot(1, xlim = c(0, 10), ylim = c(0, 4), type = "n", ann = FALSE, axes =
FALSE)
> > # text(1:10, 2, c("a","b"), cex = seqcex, family="mono",font=2)
> >
> > Which results in the error:
> > Error in text.default(1:10, 2, c("a", "b"), cex = seqcex, family = "mono",  
> > :
> >  family 'mono' not included in PostScript device
> >
> > 'mono' is perfectly fine for my x11 device and
> > # postscriptFonts()$mono
> >
> > gives me:
> > $family
> > [1] "Courier"
> >
> > $metrics
> > [1] "Courier.afm" "Courier-Bold.afm"
> > [3] "Courier-Oblique.afm" "Courier-BoldOblique.afm"
> > [5] "Symbol.afm"
> >
> > $encoding
> > [1] "default"
> >
> > attr(,"class")
> > [1] "Type1Font"
> >
> > That looks all right to me no? How to remedy this?
> 
> Use the 'fonts' argument to postscript():
> 
Hmmm, my actual function contains this bit ... any idea on how to solve this as
generic as possible? I do not want to make this require or prevent postscript as
the dev, but make the test (postscript) pass and enable future use of postscript
... where to put the 'fonts' unobtrusively, so that other devs will still work?

Joh

vectorsequence <- c("A","B")
xreq <- length(vectorsequence)

par(mar=c(1, 1, 1, 1) + 0.1)
plot(1, xlim = c(0, xreq), ylim = c(0, 4), type = "n", ann = FALSE, axes = 
FALSE)
text(1:xreq, 2, vectorsequence, cex = 2.5, family="mono",font=2)

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


Re: [Rd] Plot definition for custom class

2008-01-24 Thread Johannes Graumann
Kurt Hornik  wu-wien.ac.at> writes:

> 
> >>>>> Johannes Graumann writes:
> 
> > Hi,
> > Is there any way to trick R CMD check into not throwing this error after I
> > created a dedicated "plot" incarnation for my custom function?
> 
> > * checking S3 generic/method consistency ... WARNING
> > plot:
> >   function(x, ...)
> > plot.MQUSpecMatch:
> >   function(x, mozlabel, labelcex)
> 
> Yes (even though it is a warning and not an error): add the ... args to
> the method.
Warning get obnoxious in a big project (by my humble standars) ...
Thanks - works like a charm.

Joh

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


Re: [Rd] R CMD check and postscript fonts

2008-01-25 Thread Johannes Graumann
Prof Brian Ripley wrote:

> On Thu, 24 Jan 2008, Johannes Graumann wrote:
> 
>> Prof Brian Ripley  stats.ox.ac.uk> writes:
>>
>>>
>>> On Thu, 24 Jan 2008, Johannes Graumann wrote:
>>>
>>>> Hello,
>>>> I came across this by using R cmd check - otherwise I would probably
>>>> not have noticed.
>>>> One of my functions does something like this:
>>>> # postscript()
>>>> # plot(1, xlim = c(0, 10), ylim = c(0, 4), type = "n", ann = FALSE,
>>>> # axes =
>> FALSE)
>>>> # text(1:10, 2, c("a","b"), cex = seqcex, family="mono",font=2)
>>>>
>>>> Which results in the error:
>>>> Error in text.default(1:10, 2, c("a", "b"), cex = seqcex, family =
>>>> "mono",  :
>>>>  family 'mono' not included in PostScript device
>>>>
>>>> 'mono' is perfectly fine for my x11 device and
>>>> # postscriptFonts()$mono
>>>>
>>>> gives me:
>>>> $family
>>>> [1] "Courier"
>>>>
>>>> $metrics
>>>> [1] "Courier.afm" "Courier-Bold.afm"
>>>> [3] "Courier-Oblique.afm" "Courier-BoldOblique.afm"
>>>> [5] "Symbol.afm"
>>>>
>>>> $encoding
>>>> [1] "default"
>>>>
>>>> attr(,"class")
>>>> [1] "Type1Font"
>>>>
>>>> That looks all right to me no? How to remedy this?
>>>
>>> Use the 'fonts' argument to postscript():
>>>
>> Hmmm, my actual function contains this bit ... any idea on how to solve
>> this as generic as possible? I do not want to make this require or
>> prevent postscript as the dev, but make the test (postscript) pass and
>> enable future use of postscript ... where to put the 'fonts'
>> unobtrusively, so that other devs will still work?
> 
> It is device-specific.
For now I'm going with 

if(names(dev.list())[length(dev.list())]=="postscript"){
  text(1:xreq, 2, vectorsequence, cex = seqcex, fonts="mono",font=2)
} else {
  text(1:xreq, 2, vectorsequence, cex = seqcex, family="mono",font=2)
}

and will extend as I eun into trouble with more devices. Thanks for your
help.

Joh

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


Re: [Rd] R CMD check and postscript fonts

2008-01-25 Thread Johannes Graumann
Johannes Graumann wrote:

> Prof Brian Ripley wrote:
> 
>> On Thu, 24 Jan 2008, Johannes Graumann wrote:
>> 
>>> Prof Brian Ripley  stats.ox.ac.uk> writes:
>>>
>>>>
>>>> On Thu, 24 Jan 2008, Johannes Graumann wrote:
>>>>
>>>>> Hello,
>>>>> I came across this by using R cmd check - otherwise I would probably
>>>>> not have noticed.
>>>>> One of my functions does something like this:
>>>>> # postscript()
>>>>> # plot(1, xlim = c(0, 10), ylim = c(0, 4), type = "n", ann = FALSE,
>>>>> # axes =
>>> FALSE)
>>>>> # text(1:10, 2, c("a","b"), cex = seqcex, family="mono",font=2)
>>>>>
>>>>> Which results in the error:
>>>>> Error in text.default(1:10, 2, c("a", "b"), cex = seqcex, family =
>>>>> "mono",  :
>>>>>  family 'mono' not included in PostScript device
>>>>>
>>>>> 'mono' is perfectly fine for my x11 device and
>>>>> # postscriptFonts()$mono
>>>>>
>>>>> gives me:
>>>>> $family
>>>>> [1] "Courier"
>>>>>
>>>>> $metrics
>>>>> [1] "Courier.afm" "Courier-Bold.afm"
>>>>> [3] "Courier-Oblique.afm" "Courier-BoldOblique.afm"
>>>>> [5] "Symbol.afm"
>>>>>
>>>>> $encoding
>>>>> [1] "default"
>>>>>
>>>>> attr(,"class")
>>>>> [1] "Type1Font"
>>>>>
>>>>> That looks all right to me no? How to remedy this?
>>>>
>>>> Use the 'fonts' argument to postscript():
>>>>
>>> Hmmm, my actual function contains this bit ... any idea on how to solve
>>> this as generic as possible? I do not want to make this require or
>>> prevent postscript as the dev, but make the test (postscript) pass and
>>> enable future use of postscript ... where to put the 'fonts'
>>> unobtrusively, so that other devs will still work?
>> 
>> It is device-specific.
> For now I'm going with
> 
> if(names(dev.list())[length(dev.list())]=="postscript"){
>   text(1:xreq, 2, vectorsequence, cex = seqcex, fonts="mono",font=2)
> } else {
>   text(1:xreq, 2, vectorsequence, cex = seqcex, family="mono",font=2)
> }
This just gives me issues if someone wants to plot to a on-screen device
(like windows or x11) and uses the gui to export to postscript: the plot
was produced with the 'family' option, but the postscript device it is now
piped to will not take it. Is there any way I could code around this
generally?

Thanks, Joh

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