From bmontgomery @end|ng |rom y@hoo@com  Tue Feb 26 05:18:19 2019
From: bmontgomery @end|ng |rom y@hoo@com (Brian Montgomery)
Date: Tue, 26 Feb 2019 04:18:19 +0000 (UTC)
Subject: [Rd] Intermittent crashes with inset `[<-` command
References: <1345861204.5109355.1551154699341.ref@mail.yahoo.com>
Message-ID: <1345861204.5109355.1551154699341@mail.yahoo.com>

The following code crashes after about 300 iterations on my?x86_64-w64-mingw32?machine on R 3.5.2 --vanilla.??
Others have duplicated this (see?https://github.com/tidyverse/magrittr/issues/190?if necessary), but I don't know how machine/OS-dependent it may be.??
If it doesn't crash for you, please try increasing the length of the x vector.

Substituting the commented-out line for the one below it works correctly (prints out 1:1000 and ends normally) every time.

x <- 1:200000
y <- rep(letters[1:5], length(x) / 5L)
for (i in 1:1000) {
? # x[y == 'a'] <- x[y == 'b']
? x <- `[<-`(x, y == 'a', x[y == 'b'])
? cat(i, '')
}
cat('\n')

The point of using this syntax is to make it work better with pipes, but the errors occur without pipes or magrittr.

Thank you for your help!



[Rd] Intermittent crashes with inset `[<-` command
Brian Montgomery