[Rd] Plans for tighter integration of reference classes in R.

2010-10-23 Thread Vitalie S.
Hello Everyone! Here are a couple of thought/questions on refClasses integration in R core functionality. First, coexistence with S4: > X <- setRefClass("classX", fields = c("a", "b"), + representation = list(c = "character")) > x <- X$new() > x...@c <- "sss" > x An object of c

Re: [Rd] Plans for tighter integration of reference classes in R.

2010-10-24 Thread Vitalie S.
an be > referred to in a method by the reserved name .self|"|. That's a bit > vague, and it's possible that one could update the slots of .self as > part of slot assignment, but absent a serious example, it may be better > to just clarify the documentation. > > O

[Rd] "$<-" fails (invalid subscript type 'language')

2010-10-24 Thread Vitalie S.
This might be just beyond of my understanding of how assignment works in R, but the documentation does not say anything about: > tv <- c(a="dsf", b="sss") > tl <- list(232) > `$<-`(tl, tv[[1]], "sdfdsfdsfsd") Error: invalid subscript type 'language' This happens even before the method is dispatc

Re: [Rd] "$<-" fails (invalid subscript type 'language')

2010-10-24 Thread Vitalie S.
spinuvit.l...@gmail.com (Vitalie S.) writes: > This might be just beyond of my understanding of how assignment works in R, > but > the documentation does not say anything about: > >> tv <- c(a="dsf", b="sss") >> tl <- list(232) >> `$<-`(

Re: [Rd] "$<-" fails (invalid subscript type 'language')

2010-10-24 Thread Vitalie S.
David Winsemius writes: > On Oct 24, 2010, at 5:35 AM, Vitalie S. wrote: > >> >> This might be just beyond of my understanding of how assignment works in R, >> but >> the documentation does not say anything about: >> >>> tv <- c(a="d

Re: [Rd] Plans for tighter integration of reference classes in R.

2010-10-24 Thread Vitalie S.
John Chambers writes: > On 10/24/10 2:53 AM, Vitalie S. wrote: >> >> Thank you for the answer, John. >> >> John Chambers writes: >>> Second point first: The actual environment of a function is tightly >>> bound to low-level implementation at the C

Re: [Rd] "$<-" fails (invalid subscript type 'language')

2010-10-25 Thread Vitalie S.
> There are some things you are not really supposed to mess with in R... > Computing the index to $-constructs is one of them (trying to set up a > for loop as a call to `for` is another). It can be done, it's just > rather painful, and most likely not what you wanted in the first place. > Sorry,

Re: [Rd] "$<-" fails (invalid subscript type 'language')

2010-10-25 Thread Vitalie S.
Simon Urbanek writes: > On Oct 24, 2010, at 4:21 PM, Vitalie S. wrote: > >> David Winsemius writes: >> >>> On Oct 24, 2010, at 5:35 AM, Vitalie S. wrote: >>> >>>> >>>> This might be just beyond of my understanding of how assignme

Re: [Rd] Plans for tighter integration of reference classes in R.

2010-10-25 Thread Vitalie S.
John Chambers writes: >> >> Not internals of the evaluator, the .environment class. >> Something like: >>- move the .self into a super-class of envRefClass (in this case >> .environment), >>- make the method for `...@` for .environment, such that any update of the >>slots of the ob

Re: [Rd] "$<-" fails (invalid subscript type 'language')

2010-10-25 Thread Vitalie S.
spinuvit.l...@gmail.com (Vitalie S.) writes: > > I would expect the following to behave identically: > >> tv <- c(a="dsf", b="sss") >> tl <- list(232) > >> `$<-`(tl, tv[[1]], "sdfdsfdsfsd") > Error: invalid subscript ty

[Rd] expressions as active bindings?

2010-10-28 Thread Vitalie S.
Hello everyone! Would it be possible some day to use expressions as active bindings? Something like makeActiveExpression("foo", Expr0, env) where Expr0 is executed in _env_ whenever "foo" is refereed. The motivation for this question is fourfold: - need to use <<- if the active binding is

Re: [Rd] Reference Classes: Generalizing Reference Class Generator objects?

2010-10-29 Thread Vitalie S.
John Chambers writes: > Good diagnoses. > > This thread brought up a point or two that needed some fixes to the > documentation and code. They should be in > r-devel and 2.12 patched (from rev. 53471). > > Briefly: > > - Initialization methods should take account of future subclasses to your >

[Rd] "[[" strips the S4 class for classes extending environment

2010-11-10 Thread Vitalie S.
Dear Developers, A recently patched [[ for environment class returns a blank environment for a children class: setClass("myenv", contains = "environment") #[1] "myenv" env <- new("myenv") class(env) #[1] "myenv" #attr(,"package") #[1] ".GlobalEnv" env[["a"]] <- 343 class(env) [1] "environment"

[Rd] callNextMethod fails with "$" generic

2010-11-10 Thread Vitalie S.
Dear Developers, callNextMethods does not work with "$" setClass("mylist", contains = "list"): setMethod("$", signature(x = "mylist"), function (x, name){ cat("here:\n") callNextMethod() }) tl <- new("mylist") tl[["x"]] <- 343 tl$x #her

Re: [Rd] callNextMethod fails with "$" generic

2010-11-11 Thread Vitalie S.
eval(expr) > + }) > [1] "$" >> tl <- new("mylist") >> tl[["z"]] <- 1 >> tl$z > [1] 1 Thank you, that helps. > > On 11/10/10 4:49 AM, Vitalie S. wrote: >> Dear Developers, >> >> callNextMethods does not work

[Rd] Subclasses of class "call" not possible in R.

2010-11-17 Thread Vitalie S.
Hello Everyone! I am trying to extend the class "call", but keep getting errors whatever I do: setClass("mycall", contains = "call") #[1] "mycall" new("mycall") #Error in function (object) : # error in evaluating the argument 'object' in selecting a method for function #'show' new("mycall",

Re: [Rd] Reference classes: accessor functions via 'getRefClass(...)$accessors(...)'

2010-11-17 Thread Vitalie S.
"Janko Thyson" writes: > Hi there, > > I'd like to choose between an "static" and "dynamic" access of a reference > class field, say 'a'. > > myObj <- getRefClass("Blabla")$new() > > Static: myObj$a > > Dynamic: myObj$a.get() where the function retrieves the data > f

Re: [Rd] Reference Classes: removing methods -> implications for objects/instances of that class

2010-11-27 Thread Vitalie S.
"Janko Thyson" writes: > Dear list, > > just to make sure that I understand 'unregistering' methods for S4 reference > classes correctly: > > If I registered a method and want to 'unregister' (i.e. remove) this method > again, objects/instance created of the respective class still feature the > r

Re: [Rd] Ref classes: can I register fields as I register methods?

2010-11-27 Thread Vitalie S.
John Chambers writes: > Well, it's an interesting idea, and the current implementation would fit with > it. > > One catch is that it goes against any obvious notion of checking for valid > objects (admittedly, there are some difficulties in that already with active > bindings being used). > > Ano

[Rd] "+" operator on characters revisited

2011-01-22 Thread Vitalie S.
Hello everyone! Motivated by the recent post on SO http://stackoverflow.com/questions/4730551/making-a-string-concatenation-operator-in-r I wonder what is the current state of argument on making "+" to concatenate character vectors. The "+" method is still sealed for signature("character", "char

Re: [Rd] "+" operator on characters revisited

2011-01-23 Thread Vitalie S.
Gabor Grothendieck writes: > On Sat, Jan 22, 2011 at 3:08 PM, Vitalie S. wrote: >> >> Hello everyone! >> >> Motivated by the recent post on SO >> > http://stackoverflow.com/questions/4730551/making-a-string-concatenation-operator-in-r> >> I wonder wh

Re: [Rd] "+" operator on characters revisited

2011-01-23 Thread Vitalie S.
Spencer Graves writes: > On 1/23/2011 8:50 AM, peter dalgaard wrote: >> On Jan 22, 2011, at 21:08 , Vitalie S. wrote: >> >>> The only definite argument occurred in the thread against "+" operator >>> was the lack of commutativity (as if one have to pro

[Rd] getGenerics returns names what are not generics

2011-02-14 Thread Vitalie S.
Hi there, I encounter the following problem with getGenerics when Rgraphviz is installed: which(!sapply(getGenerics(), isGeneric)) #graph Rgraphviz graph Rgraphviz # 105 106 107 108 so, getGenerics returns twice graph and Rgrapviz as being generics, when they are not: i

[Rd] S4: inheritance of validity methods?

2009-08-18 Thread Vitalie S.
Dear Developers, In current implementation of validity method, objects are first coerced to superclass (slots are striped). Thus, it is not possible to write validity method which would perform some checks on children slots. Say, I want to check if number of slots in a class is equal to "n"

Re: [Rd] S4: inheritance of validity methods?

2009-08-18 Thread Vitalie S.
On Tue, 18 Aug 2009 15:42:48 +0200, Martin Morgan wrote: "Vitalie S." writes: Dear Developers, In current implementation of validity method, objects are first coerced to superclass (slots are striped). Thus, it is not possible to write validity method which would perform some

Re: [Rd] S4: inheritance of validity methods?

2009-08-18 Thread Vitalie S.
On Tue, 18 Aug 2009 18:58:27 +0200, Martin Morgan wrote: Vitalie S. wrote: On Tue, 18 Aug 2009 15:42:48 +0200, Martin Morgan wrote: "Vitalie S." writes: Dear Developers, In current implementation of validity method, objects are first coerced to superclass (slots are stri

Re: [Rd] S4: inheritance of validity methods? + Inconsistency in order of validity checks.

2009-08-20 Thread Vitalie S.
be c("B", "A", "TEST"). Instead validity uses the vector of unique labels constructed *TOPDOWN* : getAllSuperClasses(getClass("C")) [1] "B" "TESTS" "A" Apparently this is an inconsistency in implementation, isn't i

Re: [Rd] more special completions

2009-08-21 Thread Vitalie S.
On Fri, 21 Aug 2009 11:21:03 +0200, Romain Francois wrote: Hi, Would it be possible to add the capability for functions to register how they would like to complete themselves. Currently, there is the .addFunctionInfo, but it allows only functions to register a static list of potential

Re: [Rd] more special completions

2009-08-22 Thread Vitalie S.
Not sure, but another example may be a class dependent completion for generic functions depending on first argument. Like print(df,... ) where df a data.frame to complete, digits = NULL, quote = FALSE, right = TRUE, row.names = TRUE instead of only (x,...). That sort of already happens (ha

[Rd] S4: names stripped during instantiation of grandchildren of numeric class

2009-08-28 Thread Vitalie S.
Dear All, A small inconsistency (it's probably not even a buglet): setClass("A", contains="numeric") [1] "A" names(new("A", c(a=23))) [1] "a" setClass("B", contains="A") [1] "B" names(new("B", c(a=23))) NULL This is exactly that kind of behavior S4 was invented for, you expect n

Re: [Rd] forwarded: bug (?) in cut.POSIXt with "breaks"=integer

2009-10-17 Thread Vitalie S.
On Fri, 16 Oct 2009 16:12:40 +0200, Ben Bolker wrote: PS a parallel problem seems to occur in cut.Date ... cut.POSIXt and cut.Date both allow breaks to be a single integer specifying the number of breaks, and both call if(is.null(labels)) levels(res) <- as.character(breaks[-length(bre