Displaying 20 results from an estimated 10000 matches similar to: "creating a package with internal (hiden) S4 classes and methods"
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)
{
2003 Jul 23
1
S3 and S4 classes
Hi helpers,
I've been programming in R for a few months now but I still have doubts
about my code - I would like it to be completely S4-compatible. The
current code works fine but is probably 'unclean'.
I read the interesting article in the last R News and it helped me
understand the difference on the whole between S3 and S4 classes, but I
need a practical example. Could anyone
2007 Mar 30
2
Replacing slot of S4 class in method of S4 class?
Dear all,
Assume that I have an S4 class "MyClass" with a slot "myname", which
is initialized to: myname="" in method("initialize"):
myclass <- new("MyClass", myname="")
Assume that class "MyClass" has a method "mymethod":
"mymethod.MyClass" <-
function(object, myname=character(0), ...) {
2006 Mar 05
3
Where to declare S4 classes?
Dear listers,
I am making a trial to move from S3 to S4... I have created some classes
of interest and they work acceptably well for the purpose. I am now
wondering how to make them operate in a package. In clear when a package
is loaded (eg library(mypackage)) where should I put the class descriptions:
2008 Dec 22
1
How to add a slot to S4 class of an existing package?
Dear all,
Since my package is based on S4 classes, I would like to know how to add
a slot to an existing S4 class without breaking the code of users of my
package.
Assume the following S4 class:
setClass("MyClass",
representation(name = "character",
type = "character",
data = "data.frame"
),
prototype(name =
2014 Jan 07
1
Why do methods of "initialize" have no "srcref" attribute as other S4 mehtods?
For documentation we use a system that generates Rd files from special
comments in the code. (inlinedocs).
It is crucial to be able to get the defining source code for objects like
methods to extract the comments from it.
Here is an R session that shows how this works for several kinds of methods
and (at the end of the session) how if fails for methods of "initialize"
>
2017 Sep 22
0
S4 method implementation for S3 class
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 sometimes
check for applicable methods. The definition of ?sometimes? is
that methods must have been detected
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"),
2011 Feb 01
1
Help need to define method of an s4 class
I need some help in defining a "print" method for my new S4 class
definition. So fer I have worked like this:
setClass("MyClass", sealed=F, representation(slot1 = "list", #create a
new class
slot2 = "vector",
slot3 = "vector",
slot4 = "vector"))
setMethod("print",
2019 Nov 27
0
Troubles using numeric in s4 class union
>>>>> Ezra Tucker
>>>>> on Mon, 11 Nov 2019 21:47:41 +0000 writes:
> Hi all,
>
> I came across an issue in using the Matrix package which made it that I
> could only subset Matrices using the numeric class, but could not using
> integers. Steps to reproduce the problem:
>
> library(Matrix)
>
> # this class has *nothing* to do with
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
2008 Apr 22
1
graphics::Axis loosing S3/S4 class attributes of 'x' in 2.7.0 RC
Following my previous post on S3 method despatch, I put debug messages
in the code of Axis, Axis.default and plot.default in graphics/R/axis.R
and graphics/R/plot.R to print the class of x, at and y on plot. After
recompiling R, what I see is that x *lost* its class attribute (at least
for classes not known to 'graphics') in Axis, called directly from
plot.default and this could be the
2019 Nov 11
2
Troubles using numeric in s4 class union
Hi all,
I came across an issue in using the Matrix package which made it that I
could only subset Matrices using the numeric class, but could not using
integers. Steps to reproduce the problem:
library(Matrix)
# this class has *nothing* to do with Matrix
setClass("MyClass",
representation(myvalue = "numeric"),
prototype(myvalue = NA_real_))
# this class also has
2012 Jul 19
0
[LLVMdev] Supporting Classes using OCaml.
Hello all...
I'm trying to create a simple language that supports classes using the
OCaml API.
When I use the web page demo to produce the intermediate code for the
following C++ example ...
class MyClass {
public:
MyClass();
int c;
};
MyClass::MyClass () {
c=55;
}
...I get something like this ....
%class.MyClass = type { i32 }
@MyClass::MyClass() = alias void (%class.MyClass*)*
2011 Jun 06
1
Seeking help to define method for show() for an S4 object
Dear all, I have created a new S4 class with name "MyClass". Please see
below for it's definition. Now I want to create a
method for the show() function for this class. In defining this method, what
I want is, once user would like see an object of this class
some values will be displayed. Then R will ask for **press Enter**. Once
user presses enter then, remaining values will be
2002 Oct 29
2
File locking problems - v2.2.6
Hi,
I have been going crazy over the last few weeks trying to install a new
Samba server (using v2.2.1, v2.2.5 and v2.2.6) to replace a old system.
Problem seems to be with file locking on the new server - works
perfectly on old server!!
Attached are configuration files for Samba for old (smb205.conf) and new
(smb226.conf) servers, plus the source of a Cobol test program
(samtest.cbl) that
2009 May 18
1
S4 method dispatch and namespaces: why is default method selected
Hi,
I ran into the following peculiarity involving S4 method dispatch and
namespaces.
I develop a package which have a namespace and which depends on 'pixmap'
package, which itself does not have a namespace.
Now, in my package I have a class which has a slot for objects from
class "pixmap" and I
want to have a "plot" method for this new class. Not to clutter the
2004 Nov 11
1
"<<-" assignment no long work in class methods
Hi-
I used to use "<<-" to do assignment inside a class method, and
just found that now it is broken in R 2.0. For example, the
following code
-----------------------------------------------------------------------
setClass( "myclass", representation(x="numeric") )
setGeneric("incrXByOne", function(obj) standardGeneric("incrXByOne"))
2004 Jan 29
2
Object validation and formal classes
I'm using R 1.8.1 (Win32, Linux) and have some difficulties using
validation functions for S4 classes. The problem is if I specify a
validation function with setValidity("myclass", validate.myclass) object
validation is only performed when I create an instance using
new("myclass"), or when I explicitly call validObject(x) where x is of
class "myclass", of
2008 May 23
1
seeing an S4 method, not using it
Dear list,
here is a problem I met when trying to use a method for an S4 object,
without loading the package in which the method was defined. I do not
know if this is a bug, or a mistake of mine. Normally, I think the
package in which the appropriate method is defined is loaded
automatically when calling the method. The problem is that if the
package is indeed loaded automatically, the