Displaying 20 results from an estimated 20000 matches similar to: "S3 vs S4 for a simple package"
2008 Feb 04
2
a != a*1 != a+0 != +a
hits=1.0 tests=MANY_EXCLAMATIONS
X-USF-Spam-Flag: NO
Hi
I am writing a package for multivariate polynomials ('multipols')
using S3 methods.
The package includes a Ops.multipol() function for the
arithmetic methods; I would like
to define some sort of user-specified Boolean option which, if
set, would force results to be simplified as they are produced.
Call this option
2009 Mar 18
1
Why S4 methods of S3 'base' generics are not used in 'base' functions ?
Dear list,
It seems that S4 methods defined for an S3 'base' generic
are not used in 'base' functions.
This can be problematic when 'base' functions start with
something like 'as.matrix'.
### START R code
setClass("classA", contains = "matrix",
representation(realData = "numeric"))
setMethod("as.matrix",
2006 Jan 01
4
S3 vs. S4
Dear R People:
Could someone direct me to some documentation on the
difference between S3 and S4 classes, please?
For example, why would a person use one as opposed to another?
Maybe pros and cons of each?
Thanks in advance!
R Version 2.2.0 (I'm downloading the new one this afternoon!) Windows.
Happy New Year!
Sincerely,
Erin Hodgess
Associate Professor
Department of Computer and
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)
2017 Sep 22
2
S4 method implementation for S3 class
Hi all,
I'm trying to implement the matrix multiplication operator, which is
S4 generic, for an old-style S3 class. The following works as
expected:
x <- 1:10
class(x) <- "myClass"
setOldClass("myClass")
setGeneric("myMethod", function(x, y) standardGeneric("myMethod"))
setMethod("myMethod", c("myClass", "myClass"),
2018 May 24
2
Creating S3 methods for S4 classes (coming from r-package-devel)
Dear all,
I asked this question on r-package-devel but Martin Maechler pointed out
this was more suited on R-devel. So here it goes:
per the manual, one should create and register both the S3 and a S4 method
if one needs a method for an S4 class for a function using S3 dispatching.
This is cumbersome, and not very optimal.
I was wondering if there's a better way to do this. Currently I
2014 Jul 06
2
Depot for S3 to S4 generics (as in stats4)?
Dear developers,
the implementation of S4 generics for existing S3 ones in the base
package is concerned to be a threat to quick startup times [1]. But
since S4 is promoted, and S3/S4 interoperability a pain when package
developing [2], are there efforts to improve the situation? E.g. an S3
free system, etc.
A good thing [2] is the package 'stats4', including some setGeneric
calls (e.g.
2018 May 24
1
Creating S3 methods for S4 classes (coming from r-package-devel)
On Thu, May 24, 2018 at 6:20 PM, Michael Lawrence <lawrence.michael at gene.com
> wrote:
> You only have to make an S4 method if there is already an S4 generic.
> If there is just an S3 generic, then just define S3 methods on it.
I was refering to the recommendations in ?Methods_for_S3 (
https://stat.ethz.ch/R-manual/R-devel/library/methods/html/Methods_for_S3.html).
:
"Two
2009 Mar 17
1
exporting s3 and s4 methods
If a package defined an S3 generic and an S4 generic for the same function (so as to add methods for S4 classes to the existing code), how do I set up the namespace to have them exported?
With
import(stats)
exportMethods(bigglm)
importClassesFrom(DBI)
useDynLib(biglm)
export(biglm)
export(bigglm)
in NAMESPACE, the S3 generic is not exported.
> methods("bigglm")
[1] bigglm.RODBC*
2011 Sep 08
1
S4 - Upgrade options from S3
We've been running samba3 with an ldap backend for several years now in our
company. We use a separate exchange server for email, requiring users to
keep two separate passwords - one for the domain (samba) and one for
exchange.
I've been looking at samba4 for a while and am running a test server with
it, built from the latest git source as per the howto description. We would
be quite
2019 Nov 01
3
R C api for 'inherits' S3 and S4 objects
Dear R developers,
Motivated by discussion about checking inheritance of S3 and S4
objects (in head matrix/array topic) I would light to shed some light
on a minor gap about that matter in R C API.
Currently we are able to check inheritance for S3 class objects from C
in a robust way (no allocation, thread safe). This is unfortunately
not possible for S4 classes. I would kindly request new
2007 Feb 17
2
S3 vs S4 classes
I have developed a package, bayesm, which uses existing classes of
objects. I would like
to add a new class corresponding to objects from this package.
I have been reading about classes and all sources tell me that I should
use
so-called "new" or S4 classes.
However, a major purpose of defining a class for my package would be to
add methods to the existing generic functions: print,
2009 Jan 30
1
OO programming & S3/S4 paradigm - General question
Hi,
Being relatively new to OO programming and not so old on R, I noticed the possibility to do OO programming in R.
But it seems there is two "paradigms" S3 that seems the old one but is the one used in the R.oo package and S4 which seems more recent
As a starting point, which one is best to use? Is R.oo useful? what are the main difference between the two?
Any feedback
2017 Sep 22
2
S4 method implementation for S3 class
2017-09-22 19:04 GMT+02:00 Michael Lawrence <lawrence.michael at gene.com>:
> The %*% function is a primitive. As it says in the documentation under
> ?Methods_Details
>
> Methods may be defined for most primitives, and corresponding
> metadata objects will be created to store them. Calls to the
> primitive still go directly to the C code, which will
2010 Jun 13
1
S4 classes and S3 generic functions
A general goal for the next version of R is to make S4 and S3 play
better together.
As mentioned in a previous thread, one limitation has been that S3
generic functions, specifically the UseMethod() call, did not make use
of S4 inheritance when dispatching on general S4 objects.
This has been fixed in a version committed today (updated to rev 52267).
The code change is not large, but it
2005 May 23
2
Documentation of S3 and S4 classes, inheritance
I'd like to have a class A that computes a likelihood, and a subclass B
that computes the same likelihood by sometimes throws in an additional
term (B includes measurement error).
So B's likelihood needs to call A's, and then (sometimes) multiply by an
additional term.
It sounds as if, in the S3 scheme, NextMethod is supposed to do this:
like.A <- function(stuff) compute value
2008 May 04
1
S4 / S3 / Sweave problem
I'm not sure if this as a bug or something I am doing wrong. It occurs
in both 2.7.0 and 2.6.2.
require("methods")
setClassUnion("OptionalPOSIXct", c("POSIXct", "NULL"))
setClass("TSmetax",
representation(serIDs="character", ExtractionDate="OptionalPOSIXct" ))
setGeneric("TSmetax",
def= function(x,
2011 Jan 13
1
s3 methods on S4 objects
I have J Chambers wonderful text ( Software for data Analysis) and I've been
trying
my hand at some very routine S4 OOP development.
One of the things I was trying to do was to create some very basic S4
classes. The first
was simply a class that had a data.frame as part of its representation.
setClass("df",representation(dirframe="data.frame"))
The object basically
2013 Feb 11
2
S3 as domain member with S4
Hello
How to set a S3 file server as a domain member with a S4 PDC server ?
Regards
--
Herv? H?noch
Responsable informatique
Institut Sainte Catherine
250 chemin de Baigne-Pieds
CS 80005 ? 84918 AVIGNON cedex 9
T?l?phone : 04.90.27.57.44
2011 Feb 03
1
S3 method for S4 object
I am trying to extend an S3 method to work with an S4 object as well as the S3 objects it works with, but UseMethod does not seem to recognize the S4 class and dispatches to the default method. Is this to be expected or should I be looking for an error in my code?
If it is not an error in my code, is there an easy way to do this, or do I have to convert the generic to S4 and then make those