Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Intermittent problem with inset and compound assignment pipe operator #190

Closed
bkmontgom opened this issue Jan 19, 2019 · 2 comments
Closed

Comments

@bkmontgom
Copy link

Trying this again...I'm still having problems with it. #160 was closed because the error could not be reproduced.

library('magrittr')
x <- 1:200000
y <- rep(letters[1:5], length(x) / 5L)
for (i in 1:100) {
  # x[y == 'a'] <- x[y == 'b']
  x %<>% inset(y == 'a', x[y == 'b'])
  cat(i, '')
}

If you can't reproduce this error, please try increasing the length of x. The larger I make it, the more likely it is to crash R, instead of giving an error first. The error I usually get is

Error in function_list[[k]](value) : 
  incompatible types (from builtin to integer) in subassignment type fix

If the commented-out code is substituted, this works without error or crash.

@Zedseayou
Copy link

Zedseayou commented Feb 21, 2019

I can reproduce this error, but I think the issue is specifically with the compound assignment pipe, not inset. At least substituting x <- inset(x, y == 'a', x[y == 'b']) works fine for me (and I would be surprised if it didn't since it is literally a direct alias if you look at the code).

@bkmontgom
Copy link
Author

Here is what I got with x <- inset(x, y == 'a', x[y == 'b']) and no compound assignment pipe.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 Error in inset(x, y == "a", x[y == "b"]) : 
incompatible types (from builtin to integer) in subassignment type fix

The next two times R crashed after 50, then 26 times through the loop. I see that the code is a direct alias, so I can't explain this behavior.

Just to be sure, I tried x <- `[<-`(x, y == 'a', x[y == 'b']) and it crashed as well.

Since this code doesn't involve anything from magrittr, I tried removing library('magrittr') and I still got failures.

I'll have to contact the base R folks. Thank you for your help.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants