similar to: questions about setMethod("Arith", ...)

Displaying 20 results from an estimated 9000 matches similar to: "questions about setMethod("Arith", ...)"

2006 Sep 15
1
setMethod() woes
Hello everybody R version 2.4.0 alpha (2006-09-15 r39323), MacOSX 10.4.7 Next S4 problem. I have "brob" objects that are large real numbers, and now I want "glub" numbers that are to be a pair of glubs that represent complex numbers. I want to define binary operator "+" so that if either the left or right argument are glubs, it uses .ArithGlub. If either
2009 Nov 25
1
group generics
I have classes A and B, where B contains A. In the implementation of the group generic for B I would like to use the corresponding group generic for A. Is there a way to do that? I would also appreciate any comments if what I'm trying to do seems like the wrong approach. Here's a stripped down example: setClass("A",
2011 Feb 05
1
Seeking help to define method for '+'
Dear all, I am trying to define "+" method for my newly defined s4 class which is as follows: setClass("Me", sealed=F,representation(x1 = "numeric", x2 = "character")) new1 <- new("Me", x1=2, x2="comment1") new2 <- new("Me", x1=3, x2="comment1") setMethod("+", "Me",
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 Jun 07
1
Lazy Evaluation?
Hello, I've stumbled upon following problem, when trying to overload the methods for group Math for an S4-class which contains functions as slots. setClass("NumFunction", representation = list(fun = "function")) NumFunction <- function(f) new("NumFunction", fun = f) square <- function(x) x^2 NF <- NumFunction(square)
2010 Jul 07
2
how to define method for "+" function in a new class
Dear R developers, I have a new class, which I called "Molecule", and have tried to define = a "+" operation for 2 objects of this class. This is what I have written so far, although the method is not complete = (I'm trying to look at it at intermediate stages): setMethod( f=3D"+", signature(x=3D"Molecule",y=3D"Molecule"),
2011 Nov 02
1
overloading + operator for chars
Hello,   I would like to overload the "+" operator so that it can be used to concatenate two strings, e.g "John" + "Doe" = "JohnDoe". How can I 'unseal' the "+" method? > setMethod("+", signature(e1="character", e2="character"), function(e1, e2) paste(e1, e2, sep="") ) Error in
2009 Jun 23
1
implementing Maximum Likelihood with distrMod when only the PDF is known
Dear R users and Dear authors of the distr package and sequels I am trying to use the (very nice) package distrMod as I want to implement maximum likelihood (ML) fit of some univariate data for which I have derived a theoretical continuous density (pdf). As it is a parametric density, I guess that I should implement myself a new distribution of class AbscontDistributions (as stated in the pdf
2013 Feb 14
1
mapply error with Math (S4 group generic)
I get an error when using self-defined (not standard) functions with mapply with S4 objects from the raster package that I develop: "Error in as.character(sys.call(sys.parent())[[1]]) : cannot coerce type 'closure' to vector of type 'character'". Does anyone understand why? The problem is illustrated below. Thanks, Robert > # First a general example that works
2004 Apr 19
3
How to write an S4 method for sum or a Summary generic
If I have a class Foo, then i can write an S3 method for sum for it: >setClass("Foo",representation(a="integer"));aFoo=new("Foo",a=c(1:3,NA)) >sum.Foo <- function(x,na.rm){print(x);print(na.rm);sum(x at a,na.rm=na.rm)} >sum(aFoo) But how do I write an S4 method for this? All my attempts to do so have foundered. For example
2006 Oct 12
1
getMethods() not finding all methods
Running R2.4.0 on Apple Mac OS X 10.4.8, in Emacs ESS mode, and also R.app. In an attempt to learn a bit more about a particular method (geneNames in package affy) I invoked getMethods("geneNames") which produced geneNames methods, but not the one in affy (output below). I had to know the signature (AffyBatch) in order to find the method > getMethod("geneNames",
2012 Aug 05
2
setMethod sometimes fails to set package slot when signature has trailing 'ANY'
after this setClass("A") setGeneric("bar", function(x, y) standardGeneric("bar")) setMethod(bar, signature(x="A", y="A"), function(x, y) {}) setMethod(bar, signature(x="A", y="ANY"), function(x, y) {}) the method for signature c("A", "A") contains package information > str(getMethod(bar,
2008 May 23
1
Evaluation "conflict" in combination of replicate() and rexp()as variable inside a function
Dear userRs, "playing around" with combinations of replicate() and random number generating functions inside a self-defined "wrapper" function I encounterd a puzzling behaviour. The following are intentionally simple (and rather nonsense-) examples to isolate the relevant aspects. Please, note the seemingly "inconsistent" behaviour for the second call of
2006 Sep 01
1
setMethod("Logic", ...)
Hi In V&R the "polynomial" class is explicitly specified to have no logical operators: setMethod("Logic", signature(e1="polynomial"), function(e1,e2){stop ("...")}) I too have a class of objects for which I want to specify that Logic operators do not work, but executing setClass("brob", representation = representation
2004 Mar 10
2
R CMD check errors
Hello, I'm getting some error messages from R CMD check I can't deal with. I'm working under Linux with R 1.8.1 The package working directory can be found at: http://www.uni-bayreuth.de/departments/math/org/mathe7/DISTR/distr.tar.gz Here's the 00check.log produced by R CMD check distr * using log directory '/home/tom/studium/R/swp/swp/package/distr.Rcheck' * checking
2011 Sep 21
2
problem with function "Truncate" in package "distr"
Hello all, Can someone tell me why the following mixture of two log-normal distributions does not get truncated? What puzzles me is that the function works almost always, but for certain combinations (like the one below), it does not. # R code example library(distr) mix<-UnivarMixingDistribution(Lnorm(3.2,0.5),Lnorm(5.4,0.6),mixCoeff=c(0.3,0.7))
2013 Sep 03
5
Bienvenido a la lista de distribución R-help-es
Hola, ¿qué tal? Tienes que escribir a la dirección r-help-es en r-project.org, no a las que has usado (que son de administración de la lista). Un saludo, Carlos J. Gil Bellosta http://www.datanalytics.com El día 3 de septiembre de 2013 12:39, Jose Betancourt B. <betanster en gmail.com> escribió: > Quisiera saber en el paquete Epiestim > > Como lograr concatenar dos vectores,
2011 Oct 06
1
apply and functions with many arguments
Dear all, I would like to use the following function fitdist(data, distr, method=c("mle", "mme", "qme", "mge"), start=NULL, fix.arg=NULL, ...) for many different distr values like distr=c("norm","lnorm","pois") (just a small example) and take back into a list the parameter name which is what is inside distr plus what the
2009 Sep 09
1
Package that does not work until I re write the exactly the same code
Hi the list, I am writing a package in S4 and I do not manage to understand a bug. The "R CMD check" and the "R CMD build" both work. Here is links to the package (not on CRAN yet for the raison that I explain bellow): http://christophe.genolini.free.fr/aTelecharger/kml_0.5.zip http://christophe.genolini.free.fr/aTelecharger/kml_0.5.tar.gz Then I install the package and I
2018 Apr 18
2
odd assignInNamespace / setGeneric interaction
A coworker got tired of having to type 'yes' or 'no' after quitting R: he never wanted to save the R workspace when quitting. So he added assignInNamespace lines to his .Rprofile file to replace base::q with one that, by default, called the original with save="no".. utils::assignInNamespace(".qOrig", base::q, "base")