permuteGeneral alters source vector
Closed this issue · 3 comments
rbmayer commented
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 commented
@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