Displaying 20 results from an estimated 20000 matches similar to: "S4-based package failure: setGeneric example#1"
2010 Apr 19
0
S4-based package failure: setGeneric example#1
Nevermind, I figured out my problem after looking at the packS4 package.
I didn't realize that package.skeleton would build invalid R code. The
warning hints at that, but I interpreted the warning to mean that the
package.skeleton-generated code should be *edited*, and none of my edits
gave me a workable package. Now I realize that the S4-driven code from
package.skeleton can simply be
2010 Feb 08
1
using setMethod or setGeneric to change S4 accessor symbol from @ to $
I created some S4 objects that are essentially data frame objects. The S4
object definitions were necessary to verify data integrity and force a
standardized data format. I am, however, finding myself redefining all the
typical generic functions so that I can still manipulate my S4 objects as if
they were data frames ... I have used setMethod to set methods for "subset",
2012 Dec 08
1
namespace S3 and S4 generic imports cannot both be satisfied:
PkgA wishes to write a method for 'unique' on S4 class 'A'. ?Methods indicates
that one should
setGeneric("unique")
setClass("A")
unique.A <- function(x, incomparables=FALSE, ...) {}
setMethod(unique, "A", unique.A)
Both S3 and S4 methods need to be exported in the NAMESPACE
import(methods)
S3method(unique, A)
2006 Sep 12
1
package.skeleton() in R-2.4.1
Hi
R version 2.4.0 alpha (2006-09-06 r39158)
MacOSX 10.4.7
There was a thread some time ago as to whether the structure created by
package.skeleton() would pass R CMD check.
I have an example where package.skeleton() gives an R file that gives an
error when sourced.
If I type
setClass("brob",
representation = representation
2006 Apr 13
2
[R] S4 method dispatch matrixOrArray (fwd)
What a delicious example! (I'm taking the liberty of sharing it with
r-devel, since it raises some good issues.)
You have two questions, presumably:
1 - how could the order of the setMethod calls make a difference in the
results?
2 - what's causing the infinite loop & how could it be avoided, reliably?
Second question first. The danger sign is the "vector" method:
2010 Nov 10
1
S4 package warning
Hello everyone. R-2.12.0, suse linux 11.3.
I am debugging a package that uses S4 methods
and R CMD check gives the following warning:
> Warning in methods::findMethods(g, env) :
> non-generic function 'mdm' given to findMethods()
> See the information on DESCRIPTION files in the chapter 'Creating R
> packages' of the 'Writing R Extensions' manual.
I
2004 Dec 03
2
setGeneric(rm)
Hi,
We are developing a package using S4 classes. The S4 classes
are wrappers to C++ classes. So S4 classes contain an integer
that is the memory address of one C++ object. If an user
calls the rm() function, the C++ object must be deleted. But our generic
rm() function apparently doesn't work. Here is the code:
# The class
setClass("component",
2011 Jan 20
1
setGeneric for residuals, etc
I'm experimenting with a few model-fitting classes of my own. I'm
leaning towards using S4 for my classes, but the R functions I'd want to
override (residuals, predict, etc.) are all S3 methods.
As I understand it, I could do setGeneric("residuals"), then add S4
specializations to it. However, I don't understand the full
consequences of doing this. Are there any
2010 Sep 23
1
Behavior of R CMD build and library() w.r.t. setGeneric-like functions
Hello developeRs,
Apologies in advance for a rather long email, but to describe the
problem, I need to step through many details. I have been working on a
new dispatching system (futile.paradigm on CRAN) based on functional
programming concepts that is an alternative to S3 and S4 dispatching. I
use a declarative syntax using guard statements to control the
dispatching between function variants. I
2003 Jul 09
2
Packages, generics, S3 and S4
My question has two parts.
The first is with regard to the frame or environment in which generic
functions are defined in packages. It seems as though they are defined
(i.e. exist as objects) in frame 1, even when defined in a package.
The following is a short example:
setClass("track",representation(x="numeric",y="numeric"))
plotTrack <- function(x,y,...)
2005 Mar 25
1
S4 methods semantics questions
Some quick questions about S4 methods.
Does the typing of S4 methods mean that lazy evaluation is no longer
possible? It seems that you would need to evaluate the arguments to
determine their type at dispatch.
Second, what role, if any, do default arguments play in S4 methods? I
notice that you can put default arguments into generics but that the
dispatch is still done on the type of the
2009 Oct 27
1
How to reduce key strokes when defining S4 classes?
I feel tedious when I define a S4 class and the methods. For each
method, I have to call both setMethod and setGeneric (or both
setReplaceMethod and setGeneric). I would like a more compact grammar
so that I can reduce the key strokes. I'm wondering if there is a
better way available.
setClass(
Class='A',
representation=representation(
x='numeric'
)
2008 Sep 09
1
building a package that contains S4 classes and methods
Hello R users,
I am trying to make a my first package and I get an error that I can
understand. The package is build out of three files (one for functions, 1
for s4 classes and 1 for s4 methods).
Once I source them I run
package.skeleton( name="TDC" )
within a R session and I get
Creating directories ...
Creating DESCRIPTION ...
Creating Read-and-delete-me ...
Saving functions and
2010 Jun 09
0
Documenting generic S4 replacement method for package building
Dear List Members,
I'm struggling with the documentation of a generic S4 replacement method.
I've created a S4 method "lows" via
setGeneric("lows", function(object) standardGeneric("lows"))
setGeneric("lows<-", function(object, value) standardGeneric("lows<-"))
setMethod("lows", "myClass", function(object)
{
2017 Aug 01
0
Problems with S4 methods dispatching on `...` (aka dotsMethods)
Thank you Michael for updating the 3.4 branch, the `callNextMethod()` now
works for `...` methods as expected. However, I'm still missing your other
patch fixing the handling of arguments in `...` methods. It would be really
great if this bugfix could be integrated into the 3.4 branch as well, such
that the following code doesn't result in an error.
Cheers,
Andrzej
f = function(x,
2018 Apr 19
0
odd assignInNamespace / setGeneric interaction
The problem is not specific to redefining the q function, but to
the interaction of assignInNamespace and setGeneric. The
latter requires, roughtly, that the environment of the function
being replaced by an S4 generic is (or is the descendent of)
the environment in which it lives.
E.g., the following demonstrates the problem
% R --quiet --vanilla
> assignInNamespace("plot",
2014 Jul 11
1
Namespaces and S4 Generics
I've installed R-devel
R Under development (unstable) (2014-07-09 r66111)
Platform: x86_64-apple-darwin13.1.0 (64-bit)
and am trying to resolve some problems that I am seeing with my
SparseM package. In prior versions I explicitly had:
setGeneric("image", function(x, ...) standardGeneric("image"))
and then used setMethod to define a method for the class matrix.csr
but
2004 Jan 08
3
S3, S4, namespace
I have encountered an issue which I have been unable to resolve, involving
an S3 generic (print) being declared S4 generic in a package, and the method
being exported. This all works fine - the problem occurs when I try to
import the method to another package.
Here is the bit that works fine. -------------
#the .r file for package bar
2007 Jan 31
2
Problems with definitions of S4-generics
Hello all,
I'd like to report a problem related to S4 classes.
Platform:
Mac G4/400 PCI (PPC-architecture)
Mac OS 10.4.8
R 2.4.1 for Mac OS X (CRAN binary, 2006-12-19) w/ R.app 1.18
Last December, Simon Urbanek confirmed that the issue is not platform
related, and that it is most likely a bug. He suggested to post my report
to "the appropriate mailing list" -- I choose r-devel.
2011 Nov 09
1
Define S4 methods for 'plot'
Hi the list
I am creating a package and I have a problem to define a S4 method for plot.
I define a class 'A' and a class 'B'. I want to define a function plot for
signature c(A,missing) and another method plot for signature c(A,B). My code
is the following :
In /package/R/ directory:
--- main.R ---
setGeneric("plot",function(x,y,...){standardGeneric("plot")})