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

permuteGeneral alters source vector #11

Closed
rbmayer opened this issue Oct 14, 2019 · 3 comments
Closed

permuteGeneral alters source vector #11

rbmayer opened this issue Oct 14, 2019 · 3 comments
Assignees

Comments

@rbmayer
Copy link

@rbmayer rbmayer commented Oct 14, 2019

After passing a source vector from a dataframe to permuteGeneral, the source dataframe is altered.

# compare mydf before and after running permuteGeneral
> name <- c('first', 'second', 'third')
> rank <- c('1st', '2nd', '3rd')
> mydf <- data.frame(name, rank, stringsAsFactors = FALSE)

> mydf
    name rank
1  first  1st
2 second  2nd
3  third  3rd

> permutations <- permuteGeneral(mydf[,"name"], 3)

> mydf
    name rank
1  third  1st
2  first  2nd
3 second  3rd
@jwood000
Copy link
Owner

@jwood000 jwood000 commented Oct 14, 2019

@rbmayer ,

Thanks for reporting this. It is being caused by not making a full copy. We can get around that by calling Rcpp::clone. See more here https://stackoverflow.com/a/21282929.

This will be fixed in the next release. I won't close until then.

Thanks again,
Joseph Wood

@rbmayer
Copy link
Author

@rbmayer rbmayer commented Oct 14, 2019

@jwood000 Thanks for the quick response and the link to a temporary workaround.

@jwood000 jwood000 self-assigned this Oct 14, 2019
@jwood000
Copy link
Owner

@jwood000 jwood000 commented Jan 31, 2020

@rbmayer ,

This is fixed in version 2.3.6. It is on CRAN now. The binaries haven't been built for every platform, but they should be there within a couple of days.

Thanks again for reporting

@jwood000 jwood000 closed this Jan 31, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
2 participants
You can’t perform that action at this time.