Displaying 4 results from an estimated 4 matches for "counttt".
2019 Jul 07
3
Possible bug in `class<-` when a class-specific '[[.' method is defined
Hi all !
I noticed a strange behaviour of the function `class<-` when a class-specific '[[.' method is defined.
Here below a reproducible example :
#-------------------------------------------------------------------.
counttt <- 0
`[[.MYCLASS` = function(x, ...) {
counttt <<- counttt + 1
# browser()
x = NextMethod()
return(x)
}
df <- as.data.frame(matrix(1:20, nrow=5))
class(df) <- c("MYCLASS","data.frame")
counttt
# The same occurs when using structure(, class=) or attr(,&q...
2019 Jul 15
4
Possible bug in `class<-` when a class-specific '[[.' method is defined
Hello,
Clean R 3.6.1 session on Ubuntu 19.04, RStudio 1.1.453. sessionInfo() at
the end.
I can reproduce this.
counttt <- 0
`[[.MYCLASS` = function(x, ...) {
counttt <<- counttt + 1
# browser()
x = NextMethod()
return(x)
}
df <- as.data.frame(matrix(1:20, nrow=5))
class(df) <- c("MYCLASS","data.frame")
counttt
#[1] 9
But there's more. I tried to print the value...
2019 Jul 15
0
[External] Re: Possible bug in `class<-` when a class-specific '[[.' method is defined
Pasting the entire example into RStudio and hitting return to evaluate
does not show this. Evaluating the finall line to print counttt
separately does.
Looks like RStudio is calling `[[` on your object when examining the
environment for the Environment panel. If this concerns you then you
should contact RStudio.
Best,
luke
On Mon, 15 Jul 2019, Rui Barradas wrote:
> Hello,
>
> Clean R 3.6.1 session on Ubuntu 19.04, RS...
2019 Jul 15
1
Possible bug in `class<-` when a class-specific '[[.' method is defined
Hello,
Inline.
?s 14:26 de 15/07/19, Duncan Murdoch escreveu:
> On 15/07/2019 8:57 a.m., Rui Barradas wrote:
>> Hello,
>>
>> Clean R 3.6.1 session on Ubuntu 19.04, RStudio 1.1.453. sessionInfo() at
>> the end.
>
> That's not what I'd call a "clean session" with all those packages loaded:
You are right, but when I wrote that it *was* clean.