similar to: S4 property slots as functions?

Displaying 20 results from an estimated 20000 matches similar to: "S4 property slots as functions?"

2006 Dec 12
1
S4 'properties' - creating 'slot' functions?
Dear R users! Several languages like C# or VB allow one to create properties; typically these are under 'get', 'set' tags. My question is this really, what are similar or comparable strategies in R, and what might be preferred? I have a couple of situations where I want a certain computation to belong to a class, but I do not really want to seperate it out to a stand-alone
2016 Apr 23
0
S4 non-virtual class with no slots? [SOLVED]
Thanks, Martin, that (inherit from a virtual class) worked great. I already had a base class created with setUnion, and so this was an easy switch. I had assumed that since inheriting from a class without slots would produce a class without slots the result would still be virtual. Fortunately that's not the case. Ross ________________________________________ From: Martin Morgan
2008 Nov 20
1
How to convert S4 class slots into data.frame or how to assign variables of type 'Date'
Hi, I created a class (S4) with some slots like value, date, description (it's actually a financial transaction class). Now I need a method to convert this class forth and back into a single row data.frame, where every slots represents a column. This method looks at the moment like this: > setMethod("as.data.frame", "Transaction", function(x, row.names =
2013 Feb 15
1
Iterating through slots of an S4 object
I want to loop through slots of an S4 object and am unsure how to do so since the only way I can find to access them is individually in the form 'object@slotName'. I have guessed at a few possibilities which did not work and I have read some S4 object tutorials and things but still unsuccessful. I presume it is possible though? Any help would be much appreciated, Scott [[alternative
2015 May 05
0
Problem with adding slots to S4 object
Dear all, I did some more work in this. - put all the metadata in a dedicated subclass (see metadataclass branch in github repository). This doesn't solve the problem. - test the code under R 3.1.2. This gives the same problem. So this is NOT a bug introduced by R 3.2.0 :-) - Profiling the code. Below the summary (code is on GitHub). It seems like most of the time is spent by paste(). Note
2010 May 07
0
timeSeries and optional S4 slots?
Question on timeSeries and S4 classes: Consider the following: library(timeSeries) data <- rnorm(5) treg <- ts(data, frequency=4) t1 <- timeSeries(data, as.Date('2010-04-15') + 1:5) t2 <- as.timeSeries(treg) Now both t1 and t2 are timeSeries objects, yet t2 at ts is a valid slot, while t1 at ts is not. Thus the ts slot is optional. Sorry if I am misunderstanding the way S4
2008 Sep 14
0
ksvm accessing the slots of S4 object
I am using kernlab to build svm models. I am not sure how to access the different slots of the object. For instance if I want to get the nuber of support vectors for each of model I am building and store it in a vector. >ksvm.model <- ksvm(Class ~ ., data = somedata,kernel = "vanilladot", cross = 10, type ="C-svc") >names(attributes(ksvm.model)) [1] "param"
2016 Apr 22
2
S4 non-virtual class with no slots?
It seems that if an S4 class has no slots it can't be instantiated because it is assumed to be virtual. Is there a way around this other than adding a do-nothing slot? A singleton would be OK, though is not essential. Problem: EmptyFitResult <- setClass("EmptyFitResult", representation=representation()) # also tried it without the second argument. same result. > e <-
2013 Mar 01
1
S4-classes: Assignment of values to slots by reference
Dear R-users, I am working on a project that uses S4-classes. At some point I encountered the problem - well known to R - that I have to pass 3 different objects to a function, that should modify several slots of them and of course there is no passing by reference in R. Then I read this thread by Steve Lianoglou: https://stat.ethz.ch/pipermail/r-help/2010-August/250468.html, which offers from
2009 Nov 23
1
OOP with Encapsulated Class Definitions
Hi all, I'm seeking feedback (good, bad or indifferent) in regards to developing (further) a new class system for R, that uses encapsulated class definitions (i.e. the method definitions are literally inside the body of the class definition). A working (however very rough and poorly tested) system is available in my R package "oosp" with documentation in the vignette
2005 Aug 17
4
accesing slots of S4 class in C code
I am trying to use a custom S4 object in my C code and I cannot get the access to its slots working. The following is a toy example, but even this crashes. In R I have: setClass("pd", representation(data="numeric")) x <- new("pd", data=1:5) test <- function(pd.obj) { res <- .C("TestFun", pd.obj) res} test(x) (Of couse
2011 Feb 21
0
[R] S4 classes: referencing slots with other slots
Dear Development Group, In trying to answer the subject question myself, I found this thread initiated by Tony from five years ago: http://tolstoy.newcastle.edu.au/R/help/05/12/18169.html. I recently stumbled upon the following S4 answer to Tony's question: setClass("fooWfcn", representation(dat1="vector", dat2="vector",
2005 Dec 29
1
S4 classes: referencing slots with other slots
For those who suggest other ways to do this, I ALREADY HAVE ANOTHER DESIGN SOLUTION, DESCRIBED AT THE END. That being said, I want to know if it's possible to reference a slot in an S4 class from another slot, i.e. I'd like to have the "self.*" semantics of Python so that I can reuse a slot. That is, for various reasons it would be nice to be able to do something like:
2009 Sep 15
2
S3 objects in S4 slots
Hello, I am the maintainer of the stringkernels package and have come across a problem with using S3 objects in my S4 classes. Specifically, I have an S4 class with a slot that takes a text corpus as a list of character vectors. tm (version 0.5) saves corpora as lists with a class attribute of c("VCorpus", "Corpus", "list"). I don't actually need the
2005 May 11
0
RODBC Oracle and VB automation with R(D)COM
I haven't been able to find any help on this and am really struggling. I've been using RODBC 1.1-3 and R(D)COM v1.35 for a little over a year successfully with my Access Database, and now im switching to Oracle 9i. I use R 2.0.1 on a Windows XP platform, 1GB ram, 2GHz Intel Processor) When I connect through the Rgui R console, the connection is successful (but through VB the attempt
2015 May 04
2
Problem with adding slots to S4 object
Dear all, I'm trying to create a virtual S4 class with some subclasses. I noticed that adding slots to this class increases the memory use and slows the functions down. Note that I'm adding very small slots (integer or character both of length 1). I've made a reproducible example at https://github.com/ThierryO/testvirtualclass. The R CMD check --as-cran fails on the tests. Some of
2006 Nov 24
1
Missing values for S4 slots
Using R 2.4, the following fails: setClass("testc", representation(a="ANY")) makeC <- function(myarg) new("testc", a=myarg) makeC() -> Error in initialize(value, ...) : argument "myarg" is missing, with no default On the other hand, this is OK: f <- function(a) g(b=a) g <- function(b) if(missing(b)) "missing" else "valid
2003 Aug 06
1
S4 methods bug in naming of slots (PR#3665)
Hello, I am using R 1.7.1 on a Redhat Linux machine, version 7.3. The following works fine: setClass("ok", representation( "A" = "matrix", "Cmatrix" = "matrix")) new("ok", "A" = diag(4), "Cmatrix" = diag(4)) But the following doesn't work: setClass("notok", representation(
2006 Apr 20
1
S4 objects with list of objects as slots: how to subset?
Hello, I don't manage to see if you have already focussed on this point in some previous messages so I post my question: I have a little problem with the S4 style of programming. I tried to formalize my question: please consider the following example that you can run I think: #------------------ setClass("my.class1", representation( my.list =
2015 May 05
1
Problem with adding slots to S4 object
There are too many arguments in the signature of the my_inla generic. The signature defaults to every argument in the formals, which are probably already over-specified. Typically, one defines a generic with the formals (x, ...), or perhaps in this case (x, model, ...), but more on that below Unrelated to this issue, the my_inla generic is defined incorrectly. It should call