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

gtools is orphaned - Consider a replacement? #196

Open
DavisVaughan opened this issue Jun 16, 2022 · 0 comments
Open

gtools is orphaned - Consider a replacement? #196

DavisVaughan opened this issue Jun 16, 2022 · 0 comments

Comments

@DavisVaughan
Copy link

DavisVaughan commented Jun 16, 2022

Hi shinystan team,

We noticed that gtools is orphaned https://cran.r-project.org/web/packages/gtools/index.html, we were wondering if you'd consider replacing your usage of it with something else.

It seems that you use gtools::mixedsort() to ensure that sorting is done correctly with respect to numeric character strings.

# change sorting so e.g. "beta[1,1] beta[1,2] beta[2,1] beta[2,2]"
# instead of "beta[1,1] beta[2,1] beta[1,2] beta[2,2]"
ch <- gtools::mixedsort(ch)

I'm not sure the comment there is correct, because sort() works as you expect on that specific example. However, it does matter when you sort strings like c("1", "2", "10") because the 10 will come before the 2 with typical sort methods. You could use stringi instead of gtools for this purpose if you are looking for a good replacement:

# Small numbers aren't a problem with base sort()
x <- c("beta[1,1]", "beta[1,2]", "beta[2,1]", "beta[2,2]")
sort(x)
#> [1] "beta[1,1]" "beta[1,2]" "beta[2,1]" "beta[2,2]"
gtools::mixedsort(x)
#> [1] "beta[1,1]" "beta[1,2]" "beta[2,1]" "beta[2,2]"

# Maybe it was for this?
x <- c("beta[1,1]", "beta[2,1]", "beta[10,1]")
sort(x)
#> [1] "beta[1,1]"  "beta[10,1]" "beta[2,1]"
gtools::mixedsort(x)
#> [1] "beta[1,1]"  "beta[2,1]"  "beta[10,1]"

# You can sort that "correctly" with stringi instead
stringi::stri_sort(x, numeric = TRUE)
#> [1] "beta[1,1]"  "beta[2,1]"  "beta[10,1]"

Created on 2022-06-16 by the reprex package (v2.0.1)

@DavisVaughan DavisVaughan changed the title gtools is orphaned gtools is orphaned - Consider a replacement? Jun 16, 2022
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

1 participant