search for: new_class

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

Did you mean: ei_class
2020 Oct 30
1
[External] Re: Change to I() in R 4.1
...class specification. Right > now, and also with the previous implementation, we cannot do that > because attr(class(x), "package") is lost. So something like this: > > I <- function(x) > { > if (isS4(x)) { > x_class <- class(x) > new_classes <- c("AsIs", x_class) > attr(new_classes, "package") <- attr(x_class, "package") > structure(x, class=new_classes) > } else { > `class<-`(x, unique.default(c("AsIs", oldClass(x)))) > } >...
2020 Oct 30
0
Change to I() in R 4.1
...it exactly, including its full class specification. Right now, and also with the previous implementation, we cannot do that because attr(class(x), "package") is lost. So something like this: I <- function(x) { if (isS4(x)) { x_class <- class(x) new_classes <- c("AsIs", x_class) attr(new_classes, "package") <- attr(x_class, "package") structure(x, class=new_classes) } else { `class<-`(x, unique.default(c("AsIs", oldClass(x)))) } } Thanks, H. -- Her...
2020 Oct 30
2
Change to I() in R 4.1
Hi Martin, On 10/26/20 04:52, Martin Maechler wrote: >> >> Hi there, >> Is that change in R-devel intentional? >> >> library(Matrix) >> m <- as(matrix(c(0, 1)), "sparseMatrix") >> >> isS4(m) >> # [1] TRUE >> >> x <- I(m) >> # Warning message: >> # In `class<-`(x,
2024 Mar 14
1
Spurious warning in as.data.frame.factor()
...eric, 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.frame, foo) <- function(x) structure( # this is probably not generally correct list(x), names = deparse1(substitute(x)), row.names = seq_len(length(x)), class = 'data.frame' ) str(as.data.frame(foo(pi))) # 'data.frame':...
2024 Mar 15
2
Spurious warning in as.data.frame.factor()
...sses: > 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.frame, foo) <- function(x) structure( > # this is probably not generally correct > list(x), > names = deparse1(substitute(x)), > row.names = seq_len(length(x)), > class = 'data.frame...
2024 Mar 15
1
Spurious warning in as.data.frame.factor()
...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.frame, foo) <- function(x) structure( >> # this is probably not generally correct >> list(x), >> names = deparse1(substitute(x)), >> row.names = seq_len(length(x)), >> 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)) > > > > ???