Dear all,
I have a generic function and a bunch of methods defined in a separate
environment. Here is a reduced example:
env <- local({
# define the generic function and the method
myfun <- function(x) UseMethod("myfun")
myfun.myclass <- function(x) print("called myfun.myclas
On 30/06/2021 5:22 a.m., Taras Zakharko wrote:
Dear all,
I have a generic function and a bunch of methods defined in a separate
environment. Here is a reduced example:
env <- local({
# define the generic function and the method
myfun <- function(x) UseMethod("myfun")
myfu
On Wed, Jun 30, 2021 at 5:17 AM Duncan Murdoch wrote:
>
> On 30/06/2021 5:22 a.m., Taras Zakharko wrote:
> > Dear all,
> >
> > I have a generic function and a bunch of methods defined in a separate
> > environment. Here is a reduced example:
> >
> > env <- local({
> > # define the gener
@Duncan: .S3method() calls registerS3method() with appropriate environmental
argument under the good, so that’s not the problem.
Anyway, I’ve been doing some debugging and I think I have found the issue. The
following snippet in src/objects.c
(https://github.com/wch/r-source/blob/ecc633b37d77f
I had another glance at the code and now I’m convinced that this is the bug in
registerS3method(). Default R behavior (in objects.c) appears to be to look for
method definitions in the top environment, not the defining environment, but
registerS3method() registers the method in the defining envi
On 30/06/2021 6:51 a.m., Taras Zakharko wrote:
@Duncan: .S3method() calls registerS3method() with appropriate environmental
argument under the good, so that’s not the problem.
Anyway, I’ve been doing some debugging and I think I have found the issue. The
following snippet in src/objects.c
(ht
On 30/06/2021 7:23 a.m., Taras Zakharko wrote:
I had another glance at the code and now I’m convinced that this is the bug in
registerS3method(). Default R behavior (in objects.c) appears to be to look for
method definitions in the top environment, not the defining environment, but
registerS3m
Thats not how I read the code? Consider this snippet from registerS3method:
genfun <- get(genname, envir = envir)
if (.isMethodsDispatchOn() && methods::is(genfun, "genericFunction"))
genfun <- methods::finalDefaultMethod(genfun@default)
if (typeof(genfun) == "closure"
On 30/06/2021 7:37 a.m., Taras Zakharko wrote:
Thats not how I read the code? Consider this snippet from registerS3method:
genfun <- get(genname, envir = envir)
if (.isMethodsDispatchOn() && methods::is(genfun, "genericFunction"))
genfun <- methods::finalDefaultMethod(genfu
Thanks Duncan, I will submit a bug report to R core then.
Best,
Taras
> On 30 Jun 2021, at 14:16, Duncan Murdoch wrote:
>
> On 30/06/2021 7:37 a.m., Taras Zakharko wrote:
>> Thats not how I read the code? Consider this snippet from registerS3method:
>> genfun <- get(genname, envir = envir)
>
One error in my workaround: it also ignores
_R_S3_METHOD_LOOKUP_USE_TOPENV_AS_DEFENV_. If that evaluates to FALSE,
it shouldn't need to make any changes.
Duncan Murdoch
On 30/06/2021 9:20 a.m., Taras Zakharko wrote:
Thanks Duncan, I will submit a bug report to R core then.
Best,
Taras
O
I have opened a bug report here:
https://bugs.r-project.org/bugzilla/show_bug.cgi?id=18138
Regarding _R_S3_METHOD_LOOKUP_USE_TOPENV_AS_DEFENV_… maybe it’s a good time to
consider purging it alltogether? This behavior appears to be completely
undocumented and this variable is mentioned exactly t
Apologies if this is a well-worn question; I haven’t found it so far but
there's a lot of r-dev and I may have missed it in the archives. In the mean
time:
I've managed to avoid writing csv files with R for a couple of decades but
we're swopping data with a collaborator and I've tripped over an
Hi Stephen,
Personally, I don't have super strong feelings about this, but
https://datatracker.ietf.org/doc/html/rfc4180#section-2 does say that the
optional header line should have the same number of fields as the data
records, so in as much as that is the "CSV specification", R's read.csv
behavi
A colleague recently submitted a paper to JSS and was advised to
address the following warning which occurs when their package
(https://CRAN.R-project.org/package=pcoxtime) is loaded:
Warning message:
In .recacheSubclasses(def@className, def, env) :
undefined subclass "numericVector" of
Stephen,
the "unhelpful" column are the row names. They are considered an important part
of a data frame and therefore the default (row.names = TRUE) is to not lose
them (as there is no way back once you do). If you don't want to preserve the
row names you can simply set row.names=FALSE.
Che
Taras,
> P.S. If you are wondering what I am trying to achieve here — we have a
> very large codebase and I am trying to use environments as a type of
> “poor man’s namespaces” to organize code in a modular fashion. But of
> course it’s all pointless if I can’t get the generics to work
> reliably.
> Ben Bolker
> on Wed, 30 Jun 2021 20:23:27 -0400 writes:
>A colleague recently submitted a paper to JSS and was
> advised to address the following warning which occurs when
> their package
> (https://CRAN.R-project.org/package=pcoxtime) is loaded:
> Warning m
18 matches
Mail list logo