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

Session crashing when using setv on character vector. #434

Closed
NicChr opened this issue Jun 24, 2023 · 2 comments
Closed

Session crashing when using setv on character vector. #434

NicChr opened this issue Jun 24, 2023 · 2 comments

Comments

@NicChr
Copy link

NicChr commented Jun 24, 2023

Hi, my R session crashes when I run the below code a few times.
I'm essentially trying to expand the group names to the length of the data, similar to GRPN(expand = TRUE) but
I'm not sure why my R session aborts. I've tried on a separate machine with similar results.

  set.seed(91301125)
  df <- data.frame(group = sample.int(10^5, 10^5, TRUE))
  g <- collapse::GRP(df)
  g_names <- collapse::GRPnames(g, force.char = TRUE)
  GRP_loc <- collapse::gsplit(NULL, g = g)
  out <- character(length(g))
  for (i in seq_along(GRP_loc)){
    collapse::setv(out, GRP_loc[[i]], g_names[i], vind1 = TRUE)
  }

I don't get any crashing when using integers:

  set.seed(91301125)
  df <- data.frame(group = sample.int(10^5, 10^5, TRUE))
  g <- collapse::GRP(df)
  g_names <- collapse::GRPnames(g, force.char = FALSE)
  GRP_loc <- collapse::gsplit(NULL, g = g)
  out <- integer(length(g))
  for (i in seq_along(GRP_loc)){
    collapse::setv(out, GRP_loc[[i]], g_names[i], vind1 = TRUE)
  }
@SebKrantz
Copy link
Owner

Thanks, I'll look into this. The efficient way to do this would however be g_names[g$group.id] instead of using a for loop.

SebKrantz added a commit that referenced this issue Jul 10, 2023
Should fix #434 (unable to reproduce it on M1 mac).
@SebKrantz
Copy link
Owner

If you can check this for me still using the fix I just pushed to master. I am unable to reproduce the issue on the M1, but I think it is a protect bug.

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