Displaying 20 results from an estimated 1000 matches similar to: "How S3method() is implemented and called? And when to use it?"
2010 Feb 14
2
Portability of a C function
Hi the list,
In a package P1, I write a function f1 in C, potentially an internal
function (not to be called from R).
In a package P2, I write a function f2 in C. The f2 function needs to
use f1 from P1. Is it possible ?
--- 8< ---- In file P1.c ---------
double f1(x,y){
....
}
--- 8< ---- In file P2.c ---------
void f2(x,y,z){
double result;
....
result = f1(x,y);
....
}
2019 May 14
2
[R-pkg-devel] Three-argument S3method declaration does not seem to affect dispatching from inside the package.
CCing r-devel.
On Tue, 14 May 2019 at 02:11, Pavel Krivitsky <pavel at uow.edu.au> wrote:
>
> Dear All,
>
> I've run into this while updating a package with unfortunately named
> legacy functions. It seems like something that might be worth changing
> in R, and I want to get a sense of whether this is a problem before
> submitting a report to the Bugzilla.
>
>
2007 Nov 05
2
namespace crash on S3method("as.ff",function)
Dear all,
I have defined a generic as.ff(x, ...) and a method as.ff.function(x, ...) which converts a standard R function x into a chunked version operating on large ff objects. Everything works fine, but when registering
S3method("as.ff",function)
in NAMESPACE, the installation fails with some kind of parsing error:
adding build stamp to DESCRIPTION
installing NAMESPACE file
2019 May 14
2
[R-pkg-devel] Three-argument S3method declaration does not seem to affect dispatching from inside the package.
On Tue, 14 May 2019 at 12:31, Pavel Krivitsky <pavel at uow.edu.au> wrote:
>
> > Note that disabling name-based dispatch implies two things: 1) the
> > inability to override your method by defining gen.formula in the
> > global environment, and 2) another package can break yours (i.e.,
> > internal calls to gen()) by registering an S3 method for gen() after
>
2019 May 19
2
[R-pkg-devel] Three-argument S3method declaration does not seem to affect dispatching from inside the package.
On Sat, 18 May 2019 at 23:34, Pavel Krivitsky <pavel at uow.edu.au> wrote:
>
> > The issue here is that you are registering a non-standard name
> > (.gen.formula) for that generic and then defining what would be the
> > standard name (gen.formula) for... what purpose? IMHO, this is a bad
> > practice and should be avoided.
>
> The situation initially arose
2010 Feb 15
3
executable R script under xp (to avoid migration toward Matlab or C++)
Hello,
I discovered R two years ago and thanks to the R-community I managed to
write some scripts to analyze my data stored in mysql databases.
The only problem is that I am the only one using R in the lab. Colleagues
mainly use Matlab (but not with mysql, only with text files) but regularly
come to me to get data treated with R-scripts !!!.
To allow the use of my scripts by other people, my
2019 May 14
0
[R-pkg-devel] Three-argument S3method declaration does not seem to affect dispatching from inside the package.
Hi, I?aki,
Thanks for looking into this.
On Tue, 2019-05-14 at 11:33 +0200, I?aki Ucar wrote:
> > So, calling the same generic function with the same class results
> > in different dispatching behaviour depending on whether the call is
> > from within the package doing the export or from the outside.
>
> It does not depend on whether you export gen.formula() or not. When
2009 May 27
1
"Error: package/namespace load failed"
I am writing my first R package, and I have been getting the following series of errors when I run R CMD check:
* checking S3 generic/method consistency ... WARNING
Error: package/namespace load failed for 'REEMtree'
Call sequence:
2: stop(gettextf("package/namespace load failed for '%s'", libraryPkgName(package)),
call. = FALSE, domain = NA)
1: library(package,
2015 Jul 07
3
List S3 methods and defining packages
Hi,
from the man page ?methods, I expected to be able to build pairs
(class,package) for a given S3 method, e.g., print, using
attr(methods(print), 'info').
However all the methods, except the ones defined in base or S4
methods, get the 'from' value "registered S3method for print", instead
of the actual package name (see below for the first rows).
Is this normal
2010 Nov 30
1
warning creating an as.array method in a package
[Env: R 2.11.1, Win Xp, using Eclipse/StatET]
In a package I'm working on, I want to create as.matrix() and as.array()
methods for a particular kind of
object (log odds ratios). These are returned in a loddsratio object as
the $coefficients component,
a vector, but really reflect an underlying (R-1)x(C-1)xstrata array,
whose attributes are contained in other
components.
I define coef,
2004 Oct 17
2
Errors while compiling packages with namespace?
Hello,
I try to set up namespaces for packages. It is fine for several of them,
except one whose compilation fails (under Windows XP & R 2.0.0):
---------- Making package svViews ------------
adding build stamp to DESCRIPTION
installing NAMESPACE file and metadata
Error in parse(file, n, text, prompt) : syntax error on line 21
Execution halted
make[2]: *** [nmspace] Error 1
make[1]: ***
2013 Apr 19
2
NAMESPACE and imports
I am cleaning up the rms package to not export functions not to be called
directly by users. rms uses generic functions defined in other packages.
For example there is a latex method in the Hmisc package, and rms has a
latex method for objects of class "anova.rms" so there are anova.rms and
latex.anova.rms functions in rms. I use:
2019 May 18
0
[R-pkg-devel] Three-argument S3method declaration does not seem to affect dispatching from inside the package.
Hi, Inaki,
On Tue, 2019-05-14 at 12:50 +0200, I?aki Ucar wrote:
> The thing is that, in R, "nearer" means "the calling environment"
> (and then, other things). When you call test_me(), the calling
> environment for gen() is the package namespace. When you call gen()
> directly, thenthe calling environment is the global environment. So
> what happens here follows
2010 Dec 09
1
warning creating an as.array method in a package
I posted on this topic to r-help, but never got a sufficient answer, so
I'm reposting here.
[Env: R 2.11.1, Win Xp, using Eclipse/StatET]
In a package I'm working on, I want to create as.matrix() and as.array()
methods for a particular kind of
object (log odds ratios). These are returned in a loddsratio object as
the $coefficients component,
a vector, but really reflect an underlying
2006 Sep 01
1
as.environment(NULL)
Hi
In NEWS, it says
R CMD check now tests that the package can be loaded, and that
the package and namespace (if there is one) can each be loaded
in startup code (before the standard packages are loaded).
For package "onion", I think I have followed all of
sections 1.6.1 - 1.6.6 of R-exts, and it passes R CMD check for
R-2.3.1.
However, using R version 2.4.0 Under
2019 May 19
0
[R-pkg-devel] Three-argument S3method declaration does not seem to affect dispatching from inside the package.
Hi, Inaki,
On Sun, 2019-05-19 at 16:59 +0200, I?aki Ucar wrote:
> IMO the simplest way to do this is to check who the caller was:
>
> foo <- function(x) UseMethod("foo")
> foo.bar <- function(x) {
> sc <- sys.call(-1)
> if (is.null(sc) || sc[[1]] != "foo")
> .Deprecated(msg="Calling 'foo.bar' directly is deprecated")
2013 Apr 24
1
Problem with S3 method dispatch and NAMESPACE
I have updated the rms package to extensively use NAMESPACE. I cannot get
certain S3 methods to dispatch. For example I have in NAMESPACE
S3method(anova, rms)
S3method(latex, anova.rms)
anova.rms produces an object of class "anova.rms" and there is a
latex.anova.rms function in rms. But when I do latex(anova(fit)) I get an
invocation of latex.default.
I have tried using
2016 Nov 11
0
.S3methods: issue in content of info data.frame
Hi,
I was trying to get a list of S3 method for a given generic, along with the
package in which they are defined, and I came across what looks like an
issue in the data.frame returned in attribute 'info'. The column 'from'
mostly gets the value "registered S3method for ..." except for visible
methods. Is this the expected behavior?
See code and output below.
Thank you.
2010 Sep 01
1
S3 method for package listed in suggest/enhance
Hi all,
The profr package provides a method for displaying its output with
ggplot: ggplot.print. You don't need this ggplot2 to use profr, so
ggplot2 is listed under enhances in the DESCRIPTION file.
If I have just S3method(ggplot, profr) in my NAMESPACE, then I get:
** testing if installed package can be loaded
Error : object 'ggplot' not found whilst loading namespace
2015 May 04
1
Define replacement functions
No. I fixed that, the NAMESPACE file now contains:
S3method("[[<-", mylist)
S3method("$<-", mylist)
It still does not work. I also created a print method (print.mylist) which did work out of the box, regardless of being in the NAMESPACE file or not. Could it be somehow in here (also in my NAMESPACE file):
exportPattern("^[[:alpha:]]+")
Or could it be that