similar to: S4 extends a class, but .Data slot has different class

Displaying 20 results from an estimated 10000 matches similar to: "S4 extends a class, but .Data slot has different class"

2005 Jan 07
1
S4 class no longer accepts matrix in array slot under 2.0.1
I have an S4 class with a slot of class "array", and in upgrading to 2.0.1 (from 1.9.1) I have encountered a change in behaviour. This causes me some difficulties if I want to allow 2-dimensional arrays in the slot. The following (in 2.0.1) illustrates the point: > setClass("foo",representation("array")) [1] "foo" > a <-
2005 Jan 09
1
S4 class no longer accepts matrix in array slot under 2.0.1
I have an S4 class with a slot of class "array", and in upgrading to 2.0.1 (from 1.9.1) I have encountered a change in behaviour. This causes me some difficulties if I want to allow 2-dimensional arrays in the slot. The following (in 2.0.1) illustrates the point: > setClass("foo",representation("array")) [1] "foo" > a <-
2020 Oct 05
2
S4 - inheritance changed by order of setClassUnion and setAs()
Dear colleagues, there is a behaviour with S4 (virtual) classes that I find very hard to understand: Depending on the position of setAs(), the tree of inheritance changes. This is my baseline example that defines the classes "grandma", "mother", "daughter" and a virtual class "mr_x". For a new instance if "daughter", "mr_x" is betweeen
2003 Nov 04
2
Object saved from 1.7.1, loaded in 1.8.0
I am having difficulty using in 1.8.0 an object created under 1.7.1. The following is a 'minimal example' of the issue. First the part in 1.7.1: > require("methods") [1] TRUE > setClass("foo",representation("vector",label="character")) [1] "foo" > x <- new("foo",1:2,label=LETTERS[1:2]) >
2009 Jun 29
1
S4 and connection slot [Sec=Unclassified]
Hi all, I am having a problem trying to declare a slot representation to hold a file connection. With V2.8.0 I had been using: setClass("Element", representation( [other slots removed], datafileConn = setOldClass(c("file","connection")) ) ) This resulted in a warning but still ran okay. No however with V2.9.0 I am getting
2006 Jan 19
2
creating objects with a slot of class formula, using new
Hi, This works fine. >setClass("a",representation(b="list",c="list")) >new("a",b=list(7)) >An object of class "a" Slot "b": [[1]] [1] 7 Slot "c": list() But, now suppose you want a slot to accept an object of class formula... >setClass("a",representation(b="list",c="formula"))
2020 Oct 06
0
S4 - inheritance changed by order of setClassUnion and setAs()
Andreas, As far as I can tell (/conjecture), this is because the list of classes a particular class inherits from directly is appended to as needed, and so the order that a class extends others isd refined by the order that those connections are defined. We can see this with two setClassUnion calls, rather than required setAs: > setClass("grandma", slots = c(a =
2010 May 17
1
format.data.frame containing S4 class with format method
Hi again, I must be misunderstanding something fundamental about how an S4 class stored in a data.frame can be persuaded to print according to a desired format. The help page says: format.data.frame formats the data frame column by column, applying the appropriate method of format for each column. Here is my class: > setClass("A",contains="character") [1] "A"
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,...)
2007 Jan 24
1
how to properly extend s3 data.frames with s4 classes?
Dear R Programmers! After some time of using R I decided to work through John Chambers book "Programming with Data" to learn what these S4 classes are all about and how they work in R. (I regret not having picked up this rather fine book earlier!) I know from the documentation and the mailing archives that S4 in R is not 100% the book and that there are issues especially with
2011 Jun 23
1
Class not found when search in .onLoad
Hi, I am facing with a strange behaviour of isClass and extends when these are called in .onLoad in both R 2.12.1 and R 2.13.0. This is preventing my package from doing some object initializations at a proper place (i.e. in .onLoad). Suppose one defines two S4 classes in a package, and that one needs to check the inheritance between these two when loading the package (e.g. to validate slots
2004 Oct 25
1
usage and behavior of 'setIs'
Hello, am I using 'setIs' in the correct way in the subsequent (artifical) example? Do I have to specify explicit 'setAs' for 'list' and 'vector' or should this work automatically, since "getClass("List1")" states an explicit coerce also for these classes. I'm working with R 2.0.0 Patched (2004-10-06) on windows 2000. Thanks for your
2009 Jul 09
1
class export in package creation / setClass / namespace?
Dear all, I have been trying to create an R package. This has been successfull until I tried to define classes. Currently, my procedure is the following: Start R, load the function and class definition >tmp <- function (x) {x} >setClass("rpa", contains = "list", where=topenv(parent.frame())) Use package skeleton to create directory structure:
2009 Oct 13
1
for loop over S4
Hello, Consider this : > setClass("track", representation(x="numeric", y="numeric")) [1] "track" > o <- new( "track", x = 1, y = 2 ) > for( i in o ){ + cat( "hello\n") + } Error: invalid type/length (S4/1) in vector allocation This happens at those lines of do_for: n = LENGTH(val); PROTECT_WITH_INDEX(v =
2004 Jul 22
2
Files and classes in a package?
While installing my small package, I met a tricky problem. For clarity, let me explain it with the following simplified example. In ~/pkg/R/aclass.R, setClass("aclass", contains="bclass", representation(i="numeric")) In ~/pkg/R/bclass.R, setClass("bclass", representation(j="numeric")) After building a "pkg" package, the file
2006 Apr 12
1
S4 class slot names
Hi, Why doesn't this work? setClass("test",representation(names="character")) tmp <- new("test") tmp@names <- "a" Error in "slot<-"(object, name, TRUE, value) : 'names' attribute [1] must be the same length as the vector [0] Why does this work (replace names with name)?
2010 Jul 12
1
S4 class extends "data.frame", getDataPart sees "list"
R-Devel: When I get the data part of an S4 class that contains="data.frame", it gives me a list, even when the "data.frame" is the S4 version: > d<-data.frame(x=1:3) > isS4(d) [1] FALSE # of course > dS4<-new("data.frame",d) > isS4(dS4) [1] TRUE # ok > class(dS4) [1] "data.frame"
2008 Feb 17
1
NAMESPACEs and S4 classes
I'd like to have two packages with S4 classes with the same name but different implementation. To that end I create a package tmpA with setClass("A", representation=representation( x="numeric"), sealed=TRUE) setClass("B", representation=representation( x="numeric")) B <- function(...)
2004 Oct 06
1
R 2.0.0: namespaces, S4 classes & versioned package installation: failure to resolve correct pkg version
Hi, further down from the problem I asked about yesterday I encounter the following problem (please appologize for the lengthy mail - I have not found a brief example making the issue clear): - using R packages making use of namespaces & - S4 classes when using --with-package-versions in the install call: Pkgs install ok and the first pkg 'base' can be loaded in R
2006 Apr 07
4
setIs and method dispatch in S4 classes
Dear all, I have a question regarding setIs and method dispatch in S4 classes: Consider the following example: ##################################################### ## A02 "contains" A01 by setIs: setClass("A01", representation(a="numeric",b="numeric")) setClass("A02", representation(a="numeric",d="numeric"))