search for: new_generic

Displaying 7 results from an estimated 7 matches for "new_generic".

2023 Mar 08
1
Augment base::replace(x, list, value) to allow list= to be a predicate?
...similar to what Pavel is proposing, but structurally different. gsubfn() is more complicated than a simple switch in the body of the function, and wouldn't work well as an anonymous function. Multiple dispatch can nicely encompass both of these cases. For replace(), library(S7) replace <- new_generic("replace", c("x", "list"), function(x, list, values, ...) { S7_dispatch() }) method(replace, list(class_any, class_any)) <- base::replace method(replace, list(class_any, class_function)) <- function(x, list, values, ...) { replace(x, list(x, ...), values) }...
2005 Dec 16
3
Help with error
I am getting this error NoMethodError in Admin#add_to_project undefined method `find'' for #<Project:0x249da88> RAILS_ROOT: script/../config/.. Application Trace | Framework Trace | Full Trace /usr/lib/ruby/gems/1.8/gems/activerecord-1.13.2/lib/active_record/ base.rb:1501:in `method_missing'' ./script/../config/../app/controllers/admin_controller.rb:65:in
2023 Mar 07
1
Augment base::replace(x, list, value) to allow list= to be a predicate?
This could be extended to sub and gsub as well which gsubfn in the gusbfn package already does: library(gsubfn) gsubfn("^..", toupper, c("abc", "xyz")) ## [1] "ABc" "XYz" On Fri, Mar 3, 2023 at 7:22?PM Pavel Krivitsky <p.krivitsky at unsw.edu.au> wrote: > > Dear All, > > Currently, list= in base::replace(x, list, value)
2024 Mar 14
1
Spurious warning in as.data.frame.factor()
...tin Maechler <maechler at stat.math.ethz.ch> wrote: > Anybody trying S7 examples and see if they work w/o producing > wrong warnings? It looks like this is not applicable to S7. If I overwrite as.data.frame with a newly created S7 generic, it fails to dispatch on existing S3 classes: new_generic('as.data.frame', 'x')(factor(1)) # Error: Can't find method for `as.data.frame(S3<factor>)`. But there is no need to overwrite the generic, because S7 classes should work with existing S3 generics: foo <- new_class('foo', parent = class_double) method(as.data....
2024 Mar 15
2
Spurious warning in as.data.frame.factor()
...rote: >> Anybody trying S7 examples and see if they work w/o producing >> wrong warnings? > It looks like this is not applicable to S7. If I overwrite > as.data.frame with a newly created S7 generic, it fails to dispatch on > existing S3 classes: > new_generic('as.data.frame', 'x')(factor(1)) > # Error: Can't find method for `as.data.frame(S3<factor>)`. > But there is no need to overwrite the generic, because S7 classes > should work with existing S3 generics: > foo <- new_class('foo', pa...
2024 Mar 15
1
Spurious warning in as.data.frame.factor()
...Anybody trying S7 examples and see if they work w/o producing >>> wrong warnings? >> It looks like this is not applicable to S7. If I overwrite >> as.data.frame with a newly created S7 generic, it fails to dispatch on >> existing S3 classes: >> new_generic('as.data.frame', 'x')(factor(1)) >> # Error: Can't find method for `as.data.frame(S3<factor>)`. >> But there is no need to overwrite the generic, because S7 classes >> should work with existing S3 generics: >> foo <- new_class(&...
2024 Mar 14
1
Spurious warning in as.data.frame.factor()
> ? Tue, 12 Mar 2024 12:33:17 -0700 > Herv? Pag?s <hpages.on.github at gmail.com> ?????: > > The acrobatics that as.data.frame.factor() is going thru in order to > > recognize a direct call don't play nice if as.data.frame() is an S4 > > generic: > > ??? df <- as.data.frame(factor(11:12)) > > > > ???