similar to: How to write an S4 method for sum or a Summary generic

Displaying 20 results from an estimated 4000 matches similar to: "How to write an S4 method for sum or a Summary generic"

2004 Apr 20
2
Re: [R] Unexpected behaviour of identical (PR#6799)
"Swinton, Jonathan" <Jonathan.Swinton@astrazeneca.com> writes: > # works as expected > > ac <- c('A','B'); > > identical(ac,ac[1:2]) > [1] TRUE > > #but > > af <- factor(ac) > > identical(af,af[1:2]) > [1] FALSE > > Any opinions? Did a cross-check with Splus and it doesn't do that , so I think it
2006 Jan 17
1
data.matrix returns mode logical for zero rows (PR#8496)
Full_Name: Jonathan Swinton Version: 2.2.1 OS: Windows Submission from: (NULL) (193.132.159.169) #The first line of description for data.matrix says that it will # 'Return the matrix obtained by converting all the variables in a # data frame to numeric mode and then binding them together as the # columns of a matrix.' #However when called with a data.frame with zero rows,
2003 Dec 19
1
Missing arguments to new
Is this the expected and/or correct behaviour? And if so, how do I persuade new to interpret a named but missing argument as missing? ------------- setClass("testMissing",representation(a="numeric"),prototype=list(a=0)); showMissing <- function(real.arg,missing.arg) { really.missing <- new("testMissing"); show(really.missing); really.there <-
2010 Apr 09
5
SSH Through R Script
Hi, I am trying to SSH to a remote server through R script. In other words, I would like to know how I can get a SSH connection to the remote server and then execute commands on that server with the R script. So in bash, I would normally type ssh -lusername remoteserver.com; press enter and then wait for the password prompt to key in my password. I have tried system("ssh
2008 Dec 22
2
... (dotMethods) and cbind/rbind: how to give the signature?
Dear List, I'm struggling with the signature writing cbind/rbind functions for a S4 class. First of all, I'm very happy that it is now possible to dispatch on ... I follow the example for "paste" in ?dotMethods, which works as far as this: ### start example setClass ("cbtest", representation = representation (data = "data.frame"),
2014 Mar 26
5
Conflicting definitions for function redefined as S4 generics
That might be worth thinking about generally, but it would still be nice to have the base generics pre-defined, so that people are not copy and pasting the definitions everywhere, hoping that they stay consistent. On Wed, Mar 26, 2014 at 6:13 AM, Gabriel Becker <gmbecker@ucdavis.edu>wrote: > Perhaps a patch to R such that generics don't clobber each-other's method > tables
2008 Jan 22
1
deparse, substitute and S4 generics
Hello everyone, I encountered the following confusing behavior of 'deparse' and 'substitute' while programming with S4 classes (see example below). It seems like the presence of '...' argument in the definition of the generic generates the problem. I have no clue why, can anyone explain that to me? Are there any "workarounds"? Thanks a lot for your time!
2004 Nov 18
1
Method dispatch S3/S4 through optimize()
I have been running into difficulties with dispatching on an S4 class defined in the SparseM package, when the method calls are inside a function passed as the f= argument to optimize() in functions in the spdep package. The S4 methods are typically defined as: setMethod("det","matrix.csr", function(x, ...) det(chol(x))^2) that is within setMethod() rather than by name before
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",
2014 Mar 26
1
Conflicting definitions for function redefined as S4 generics
[cross-posted to R-devel and bioc-devel] Hi, I am trying to implement a 'sort' method in one of the CRAN packages I am maintaining ('apcluster'). I started with using setMethod("sort", ...) in my package, which worked fine. Since many users of my package are from the bioinformatics field, I want to ensure that my package works smoothly with Bioconductor. The problem
2004 Jul 06
1
questions about setMethod("Arith", ...)
Hi, we have some questions concerning the definition of new arithmetic methods. In our package "distr" (on CRAN) we define some new arithmetic methods for "+", "-", "*", "/". After loading "distr" the corresponding arithmetic methods work. Now, if we define a new class and also a new method for one of the arithmetic methods
2004 Aug 07
1
memory usage of S4 methods
Hi, I have some problems with the memory usage of S4-generics. For example, I observed the following behaviour: > gc() used (Mb) gc trigger (Mb) Ncells 432091 11.6 531268 14.2 Vcells 116052 0.9 786432 6.0 > setClass("A",representation(x="numeric")); [1] "A" > setClass("B",representation(x="numeric")); [1] "B"
2015 Jan 24
3
Proper way to define cbind, rbind for s4 classes in package
Hi all, this question has already been posted on stackoverflow, however without success, see also http://stackoverflow.com/questions/27886535/proper-way-to-use-cbind-rbind-with-s4-classes-in-package. I have written a package using S4 classes and would like to use the functions rbind, cbind with these defined classes. Since it does not seem to be possible to define rbind and cbind directly as S4
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
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:
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
2012 Apr 12
1
R-2.15.0 and Exporting Methods Converted To S4 Generic
Late to the show on this release, unfortunately. One of our production packages no longer builds under R-2.15.0 with the following message. ** testing if installed package can be loaded Error: Function found when exporting methods from the namespace 'SuperCurve' which is not S4 generic: 'image' Possibly relevant clues follow: ## From R/AllGenerics.R if
2005 Jun 02
1
Too generic with S4 methods?
I tried the following (relevant excerpt only) setMethod("likelihood", signature(spec="Specification", covs="vector", states="vector"), function(spec, covs, states) { #### setMethod("likelihood", signature(model="Model", path="matrix"), function(model, path) { This
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 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