Displaying 20 results from an estimated 8000 matches similar to: "setGeneric(); R CMD check"
2002 Jan 06
1
How to get setGeneric() to work?
Dear all, I can't see how setGeneric() works. I know perfectly well how to
define
library(methods);
setClass("Square", representation(side="numeric"));
# Will become the default method.
getArea <- function(object) {
stop(paste("Method getArea() is not defined for this class:",
data.class(object)));
}
setMethod("getArea",
2003 May 27
1
setGeneric?
In the last few days I've received couple of messages pointing out that our SparseM
package fails to install on the patched version of 1.7.0. Laurent Gaultier kindly
suggested that replacing:
setGeneric("as.matrix.csr")
by
setGeneric("as.matrix.csr", function(x, nrow, ncol, eps) standardGeneric("as.matrix.csr"))
was sufficient to fix the problem.
2003 Apr 01
1
setGeneric
I'm still having difficulties with methods...is the following behavior expected?
(This is without loading any libraries)
R : Copyright 2003, The R Development Core Team
Version 1.7.0 Under development (unstable) (2003-03-31)
> ls()
character(0)
>
> diag(2)
[,1] [,2]
[1,] 1 0
[2,] 0 1
> setGeneric("diag")
[1] "diag"
> diag(2)
Error in
2002 Jul 01
1
SetGeneric and formula interfaces
Hi,
while playing with the `methods' package I was not able to find what the
recommended way of dealing with the following problem is.
Suppose there is a generic function `foo' and two functions `foo.default'
and `foo.formula', in the classical way:
foo <- function(y, ...) UseMethod("foo")
foo.default <- function(y, ...) {}
foo.formula <- function(formula,
2003 Jul 15
1
dbApply (R newbee)
I am trying to use R interfaced with MySQL. Present goal is that R should
calculate the 85% quantile of AvgSpeed for each LinieID. Looking through
documentation of the RMySQL Package, I guessed that dbApply would do the
trick due to this example
## compute quanitiles for each network agent
con <- dbConnect(MySQL(), group="vitalAnalysis")
res <- dbSendQuery(con,
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,...)
2002 Feb 19
1
library(methods): setMethod with "ANY" fails. (PR#1317)
Full_Name: Henrik Bengtsson
Version: R v1.4.1
OS: WinMe
Submission from: (NULL) (217.208.14.137)
Doing the following
library(methods)
setGeneric("foo", function(x) standardGeneric("foo"))
setMethod("foo", "ANY", function(x) cat(x))
fails with
Error in while (value[n] == "ANY") n <- n - 1 :
missing value where logical needed
It
2002 May 08
1
Questions about S4 style methods and generics
I have some questions about S4 style methods and generics.
First of all, is there any way of using default values for arguments
in the generics/methods? My own experiments show that such arguments
are always ignored. The green book seems to be silent on this
matter.
The second question is about using a non-trivial function body for
generics. Page 351 of the green book gives an example of this
2003 Dec 02
1
setMethod("min", "myclass", ...)
Hello,
I have defined a new class
> setClass("myclass", representation(min = "numeric", max = "numeric"))
and want to write accessor functions, so that for
> foo = new("myclass", min = 0, max = 1)
> min(foo) # prints 0
> max(foo) # prints 1
At first i created a generic function for "min"
> setGeneric("min",
2002 Dec 30
2
Writing packages with `methods' package
I'm trying to write a package which uses classes/methods as defined in the
`methods' package. I have a single .R file which defines the class and
various methods for that class. At the top of the file I have
require(methods)
and then
setClass("myclass", ...)
setGeneric("intersect")
setMethod("intersect", "myclass", function(x,y) ...)
I noticed
2003 Aug 21
2
efficiency and memory use of S4 data objects
I do lots of analyses on large microarray data sets so memory use and speed
and both important issues for me. I have been trying to estimate the
overheads associated with using formal S4 data objects instead of ordinary
lists for large data objects. In some simple experiments (using R 1.7.1 in
Windows 2000) with large but simple objects it seems that giving a data
object a formal class
2004 Jun 26
1
S4 group "Math", "getGroupMembers", "genericForPrimitive"
Hi,
I found the following on Windows 2000/NT
R Version 1.9.1 (2004-06-21) (also Version 1.9.0):
The S4 group "Math" doesn't work as documented; i.e., "log", "log10",
"gamma" and "lgamma" are included
in the documentation but don't work. See example code below.
Moreover, what about 'genericForPrimitive' which is used
in
2004 Oct 08
1
Function _coerce_ in _setIs_ never entered (S4).
Hi,
Please consider the following trivial example.
In the sample code I first define a class MVCa using composition. This
class contains a slot of type list.
Next I define an inheritance relation using the function setIs -> MVCa
"is a" list.
Then I define a function printlength which prints the list-length which
is defined for the type "list".
If I call this function
2002 Nov 05
1
function showMethods and inheritance
Hi,
The following question might come from my (deep) misunderstanding
of the concepts in the package 'methods'.
I have a class 'A', and a class 'B' inheriting 'A' (so defined
with 'setClass' and the parameter 'contains="A"'. The class
A has a method 'mymethod'. A call to 'showMethods("mymethod")'
return the
2003 May 30
3
Missing 'getGroupMembers()'
Hi,
I'm trying to write a method such that my own classes can be used with the
groups like "Summary" and "Math", but when I tried to look for examples or
just wanted to get an idea of which functions are the members of a group, I
found out that the function "getGroupMembers" is not present... I couldn't
find an alternative function, if there is one. Does
2003 Sep 05
2
S4 Method Collisions with "[" (PR#4075)
Full_Name: Colin A. Smith
Version: 1.8.0
OS: Mac OS X 10.2.6
Submission from: (NULL) (216.102.90.18)
Both Biobase and my package annaffy use S4 classes to define methods for "[".
Both packages use the save image method of installation. (See annaffy 1.0.3 in
BioC CVS.)
Depending on how both packages are loaded, the Biobase definitions seem to be
getting masked out:
>
2003 Oct 11
2
Problem in 'methods' package (PR#4525)
Full_Name: Fernando Henrique Ferraz Pereira da Rosa
Version: 1.8.0
OS: Linux 2.4.21
Submission from: (NULL) (200.206.211.169)
After installing R 1.8.0, the R DBI interface stopped working. I tracked it
down as a problem in the 'methods' package, that comes in the default
installation.
Somehow the function '.valueClassTest' which is defined on package
'methods',
2001 Apr 24
2
assigning objects from .C/.Call
Hi,
In section 4.6.7 of "Writing R Extensions" (Version 1.2.1, 2001-01-15)
the C function defineVar() is described as "... the equivalent
of assign(symbol, value, envir = rho, inherits = FALSE) ..."
I interpreted the above (wrongly) as meaning that defineVar() makes
a copy of its "value" argument into the object whose name is specified
in "symbol" in
2002 Aug 06
2
[ and setMethod conflict?
I noticed this oddity about [ and setMethod.
First, I define testFunc, which sorts a data frame by the first column and
returns the entries that aren't NAs, and testIt, which runs testFunc
repeatedly on a random large data frame, each time saving the return into a
dummy placeholder (for demonstration's sake).
> require(methods)
Loading required package: methods
[1] TRUE
> testFunc
2002 Aug 06
2
[ and setMethod conflict?
I noticed this oddity about [ and setMethod.
First, I define testFunc, which sorts a data frame by the first column and
returns the entries that aren't NAs, and testIt, which runs testFunc
repeatedly on a random large data frame, each time saving the return into a
dummy placeholder (for demonstration's sake).
> require(methods)
Loading required package: methods
[1] TRUE
> testFunc