Displaying 7 results from an estimated 7 matches for "new_classes".
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.
--
Herv?...
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()
On Thu, 14 Mar 2024 10:41:54 +0100
Martin 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))
#
2024 Mar 15
2
Spurious warning in as.data.frame.factor()
>>>>> Ivan Krylov
>>>>> on Thu, 14 Mar 2024 14:17:38 +0300 writes:
> On Thu, 14 Mar 2024 10:41:54 +0100
> Martin 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
>
2024 Mar 15
1
Spurious warning in as.data.frame.factor()
>>>>> Martin Maechler
>>>>> on Fri, 15 Mar 2024 11:24:22 +0100 writes:
>>>>> Ivan Krylov
>>>>> on Thu, 14 Mar 2024 14:17:38 +0300 writes:
>> On Thu, 14 Mar 2024 10:41:54 +0100
>> Martin Maechler <maechler at stat.math.ethz.ch> wrote:
>>> Anybody trying S7 examples and see if they work
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))
> >
> > ???