Displaying 4 results from an estimated 4 matches for "class_double".
2024 Mar 14
1
Spurious warning in as.data.frame.factor()
...ting 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': 1 obs. of 1 variable:
# $ x: <fo...
2024 Mar 15
2
Spurious warning in as.data.frame.factor()
...s.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.fr...
2024 Mar 15
1
Spurious warning in as.data.frame.factor()
...;, '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 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))
> >
> > ???