similar to: method show

Displaying 20 results from an estimated 10000 matches similar to: "method show"

2010 Feb 26
2
New methods for generic functions show and print : some visible with ls(), some not
Dear all, I'm trying to understand the S4 way of object-oriented programming, but I still can't grasp completely what R is doing. I have a class definition for a class called PM10Meteo, and I set a initializer function. next, I include a show method and a print method as shown below. setClass( Class="PM10Meteo",...) # end setClass setMethod
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
2013 Feb 14
4
2 setGeneric's, same name, different method signatures
hi. below is a small test case (hopefully minimal, though i'm still a bit confused about initializers). i would have guessed (and maybe i still would have been right) that one could re-use the name of a generic function for functions with different numbers of arguments. in the case below, class A's bB() queries the status of a single A object, so bB(A) (where here "A" is an
2010 Mar 16
1
Problem with S3 to S4 transition
Hello to everybody I am developing a package using R and have the following problem: I used to work in a mixture of S3 and S4 mechanism environment: as a matter of fact, I used to define my classes (say "DB" for illustration) using the setClass function (with representation field), and I was using the S3 implicit mechanism writing the functions: print.DB and plot.DB. Recently, I
2010 Jun 08
2
Extract/format/show for S4 objects
Hi all, I'm trying to make an integer-backed quarter (as in fraction of year) class, but I can't quite it to work. I want integer-backed so I don't have to worry about floating-point effects when doing math, and so that I can use it as in data.table. First of all, is there a good reference for this anywhere? All of the S4 tutorials that I've found have been too high-level, and
2007 May 08
2
Problem calling $ inside a $ method
Hello, I wonder if this will make it through the spam filters given the subject line. I'm seeing the following when trying to call a dollar method inside of a dollar method. setClass("Foo", representation(d="list")) [1] "Foo" f <- new("Foo", d=list(bob=1, alice=2)) ## We can call dollar at this level and it works as expected
2010 Jun 23
2
format: different S4 behavior in a package
R-Devel-ers: I have an S4 method that simply formats an object: setGeneric("formatMe", function(x) standardGeneric("formatMe")) setMethod("formatMe", "ANY", function(x) format(x)) If I issue the above in an R session, then define an S4 class with its own format method, I get the desired result: > setClass("A",contains="numeric")
2006 Sep 08
2
Extending [ method to S4 class and drop argument (PR#9211)
Full_Name: John Verzani Version: 2.4.0 alpha (2006-09-05 r39134) OS: linux, gentoo 2.6.17 Submission from: (NULL) (163.238.43.26) When extending the "[" method to a new S4 class, the default value for the drop argument is not being found. Here is a small example: setClass("test",representation(x="character"))
2015 May 10
2
S4 method dispatch sometimes leads to incorrect when object loaded from file?
Loading an S4 object from a file without first loading the library sometimes (?, the example below and actual example involves a virtual base class and the show generic) leads to incorrect dispatch (to the base class method). The attached package reproduces the problem. It has setClass("A") setClass("B", contains="A") setMethod("show", "A",
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 May 22
2
confused by inheritance...
Hi r-devels, I am stuck in some S4 inheritance problem: setClass("A",representation(a="numeric")) setClass("A1",representation(b="numeric"),contains="A") setClass("A2",representation(c="numeric"),contains="A1") if(!isGeneric("foo")){ setGeneric("foo", function(x,y,z, ...)
2008 May 10
2
Hashes as S4 Classes, or: How to separate environments
For learning purposes mainly I attempted to implement hashes/maps/dictionaries (Python lingua) as S4 classes, see the coding below. I came across some rough S4 edges, but in the end it worked (for one dictionary). When testing ones sees that the dictionaries D1 and D2 share their environments D1 at hash and D2 at hash, though I thought a new and empty environment would be generated each time
2011 Sep 09
3
split variable / create categories
Hi, is there a function or an easy way to convert a variable with continuous values into a categorial variable (with x levels)? here is what I mean: I want to transform x: x <- c(3.2, 1.5, 6.8, 6.9, 8.5, 9.6, 1.1, 0.6) into a 'categorial'-variable with four levels so that I get: [1] 2 2 3 3 4 4 1 1 so each element is converted into its rank- value / categorial-value (in
2006 Aug 30
1
setMethod() and log()
Hi I am having difficulty with setMethod(). I have a "brob" class of objects whose representation has two slots: "x" and "positive". Slot "x" (double) holds the log of a number and slot "positive" (logical) its sign. The idea is that large numbers can be handled. I'm trying to implement a log() method using an analogue of the
2007 Apr 19
2
setClass inside a function
Hello, I would like to create a function that gets passed a class name and then calls setClass, and a few other functions, inside. I have done this in the past with setmethod, creating accessors for all slots in a set of S4 classes. But setClass is choking when my function is called isnide a package, telling about an error in exists(cname, where). I assume this to be a problem with the
2009 Jan 02
1
"registering" a generic method for a class
Sorry in advance if this is too simple a question, but I'm stuck with some odd behavior and I can't find the text to rid myself of this (admittedly somewhat trivial) problem. Note that I've done generic programming with S3 "objects" in the past, but I've never really dabbled in creating S4 objects until now. So, I've created a new S4 class, call it
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",
2009 Jun 05
2
Problem with generic methods
Hi I want to create a new generic method, but I end up with an error (evaluation nested too deeply). see the transcript below. The function beginYear.Fun() works, but not beginYear. I have no idea why. Any ideas welcome, Rainer > setClass("fun", representation(x = "numeric")) [1] "fun" > new("fun") An object of class ?fun? Slot "x":
2012 Mar 15
1
Extending a group of S4 classes by setClassUnion ?
Hi, I would like to create some S4 classes as follows setClass("Father",representation(name="character")) setClass("Son1",contains="Father",representation(par="numeric")) setClass("Son2",contains="Father",representation(par="logical")) Son1<-new("Son1") Son1 at name<-"Son1" Son1 at par<-3
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