similar to: S4 programming

Displaying 20 results from an estimated 20000 matches similar to: "S4 programming"

2010 Mar 01
1
Method dispatch
Dear all, In a package, I defined a method for "summary" using setMethod(summary, signature="abc") for my class "abc", but when the package is loaded, the function "summary(x)" where x is of class "abc" seems to have called the default summary function for "ANY" class. Shouldn't it call the method I have defined? How could I get
2011 May 16
4
Problem on glmer
Hi all, I was trying to fit a Gamma hierarchical model using "glmer", but got weird error message that I could not understand. On the other hand, a similar call to the glmmPQL leads to results that are close to what I expect. I also tried to change tha "nAGQ" argument in "glmer", but it did not solve the problem. The model I was fitting has a simple structure - one
2010 Sep 09
5
Help on simple problem with optim
Dear all, I ran into problems with the function "optim" when I tried to do an mle estimation of a simple lognormal regression. Some warning message poped up saying NANs have been produced in the optimization process. But I could not figure out which part of my code has caused this. I wonder if anybody would help. The code is in the following and the data is in the attachment. da <-
2006 Aug 28
2
S4 classes and objects -- fixed structure? No...
Hello. Suppose you define a new S4-class, say > setClass("track", representation(x="numeric", y="numeric")) Don't worry if you have a deja vu, it's from the help page. Your new class is said to have a fixed structure: two slots, x, and y, and that should apply to all objects you construct as members of that class. > tr <- new( "track" )
2009 Jun 15
1
Create R object
Dear R users, I have two simple questions here, and hope someone can help me on this. Thanks in advance. 1. I have a list object lst=list(a1=matrix(rnorm(4),2,2), a2=matrix(rnorm(4),2,2),a3=matrix(rnorm(4),2,2)). Here I only use three elements for illustration, and in fact the length of lst, n, is unknown in advance. I want to define an object for each element of this lst, and the objects have
2007 Dec 13
1
S4 class extending data.frame?
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 I would like to build an S4 class that extends a data frame, but includes several more slots. Here's an example using integer as the base class instead: setClass("c1",representation(comment="character"),contains="integer") z1 = new("c1",55,comment="hello") z1 z1+10 z1[1] z1 at comment -- in
2010 Jan 03
5
update packages from local
Hi all, I have an old package installed, say "abc". Now I made some changes to the source, and built a new version of the source code "abc_0.1.1.tar.gz". How can I update the old package to this newer version from the local tar.gz file? I was running the following, but it did not work. setwd("directory where the tar.gz file locates")
2005 Apr 13
1
S4 extends a class, but .Data slot has different class
When I define an S4 class ("B" in the example below) that directly extends another ("A" in the example below) , which in turn directly extends another ("character" in the example below), I find that the slot does not have the class I specified in setClass(), it has the underlying class. Is this an intended feature? Briefly, the reason for using this type of
2010 Sep 02
1
Help on glm and optim
Dear all, I'm trying to use the "optim" function to replicate the results from the "glm" using an example from the help page of "glm", but I could not get the "optim" function to work. Would you please point out where I did wrong? Thanks a lot. The following is the code: # Step 1: fit the glm clotting <- data.frame( u =
2012 Nov 15
1
bug with mapply() on an S4 object
Hi, Starting with ordinary vectors, so we know what to expect: > mapply(function(x, y) {x * y}, 101:106, rep(1:3, 2)) [1] 101 204 309 104 210 318 > mapply(function(x, y) {x * y}, 101:106, 1:3) [1] 101 204 309 104 210 318 Now with an S4 object: setClass("A", representation(aa="integer")) a <- new("A", aa=101:106) > length(a)
2010 Mar 01
0
S4 issues
Dear all, I ran into some issues that I've been trying to figure out for weeks but with no success. So I'm looking for some advice here. I've the following questions: 1. I want to write some S4 classes and methods and add them into a current package that was written in S3. Is this possible? Can both S3 and S4 methods exist in one package? 2. When I sourced my functions using
2012 Apr 03
1
object of type 'S4' is not subsettable
hey there! The object 'cit' contains: > cit ##################################################### # Johansen-Procedure Unit Root / Cointegration Test # ##################################################### The value of the test statistic is: 5.3484 9.0681 10.6433 --------------- I want R to save the value 5.3484 in a new object. I am used to use the command x=cit[a] where a
2006 Oct 26
1
Pb with .findInheritedMethods
Hi again, Here is a very simplified version of a class hierarchy defined in the Biobase package (Bioconductor). I post here because this seems to be an S4 related problem: setClass("A", representation(name="character")) setMethod("initialize", "A", function(.Object) {.Object at name <- "I'm an A"; .Object})
2005 Dec 29
1
trouble with S4 methods for group "Summary"
Hello. This question concerns the Methods package. I have created a new class and am trying to set a method for it for S4 group generic "Summary". I have run into some signature problems. An example: > setClass("track", representation(x="numeric", y="character")) [1] "track" > setGeneric("max", group="Summary")
2005 Jan 14
1
RE: [R] as.character methods
Thank you for your replies. I greatly appreciate the wealth of documentation on this subject and the time spent by the John Chambers and the R Core Team making object-orient programming in R a reality. I hope to be able to give code (not just bug reports) back to the R community as my projects advance. I hoping to generalize my as.character question to a real-life as.character / print method
2010 May 21
1
S4 method defined but not used
Dear R developers, I am having a slightly weird issue with a S4 method defined in my package adegenet 1.2-4, with R 2.11.0. As far as I know, the problem is new, and the code implementing the method has not changed for more than a year and worked well so far. The problem is the following. I define, in the package, a method "[" for the S4 class 'genind'. The method's
2006 Jun 06
1
vague errors on R CMD check for very minimal S4-style package
Hello, I have a very minimal package "simplepkg" (DESCRIPTION, NAMESPACE, and R) with S4 classes/methods (defines a class "foo" and a show method for that class" - both the class and show method are exported). I can seemingly install the package, then load and use it: > sessionInfo() Version 2.3.1 (2006-06-01) sparc-sun-solaris2.10 attached base packages: [1]
2011 Jun 03
2
Bug or feature: using "ANY" as a generic field class (was: '[R] Is there a (virtual) class that all R objects inherit from?)
Dear list, I was wondering if you could help me out in clarifying something: Is it possible to use class "ANY" in slots/fields of formal classes if you a) do not want to restrict valid classes of that field and b) if you are making explicit use of class inheritance? It seems to work in simple scenarios but produces errors when class inheritance comes into play. So I was
2006 Mar 15
1
setMethod confusion -best reference for S4 programming
Thanks I think you have both answered my question (reckon Ill go S3 on that). As an adjunct to this do you know what might be the best reference to the S4 methods current implementation. I have ordered the Chambers book "Programming with Data", and I have a short tutorial-- "S4 Classes in 15 pages, more or less". Have I missed any other useful resources? Stephen Henderson
2010 Aug 30
2
S4 Method Rd Warning
Hello, I am using R 2.11.0. I have a curious problem where I get a warning in R CMD check which is seemingly not relevant to my Rd file. The warning says : * checking Rd \usage sections ... WARNING Bad \usage lines found in documentation object 'enrichmentCalc': <unescaped bksl>S4method{enrichmentCalc}{GenomeDataList, BSgenome}(rs, organism, seqLen=NULL, ...) <unescaped