Join GitHub today
GitHub is home to over 50 million developers working together to host and review code, manage projects, and build software together.
Sign upcolor_values() modifying global environment? #60
Comments
|
I think this was directly related to #24 - I missed a Please try the latest version from github devtools::install_github("SymbolixAU/colourvalues")Then you should see the expected behaviour library(colourvalues)
set.seed(123)
x <- runif(10,-10,10)
y <- x
x
y
z <- color_values(y, palette = get_palette("cividis")[256:1, ] )
x
y
zNote also that |
|
Thanks very much, @SymbolixAU. The GitHub version does indeed resolve the issue. I gather the And thanks for the tip about |
|
yeah it's a C++ thing :) |
Issue description
Satisfied colourvalues user here, but encountering some very strange behavior after updating R (session info below). When
color_values()is called, it modifies not only the object passed as thexargument, but also other object(s) that are copies ofx.This seems related to #24, but that issue focused on the difference between integer and numeric arguments. My question is rather how the function could be modifying the object in the global environment that is passed to it. This is very unexpected behavior in R, and even more surprising is that copies of that object are modified. This breaks everything I thought I knew about R.
Session info
In addition to the following info for my system, a colleague has reproduced this on a Mac (don't know session info, but would assume everything up to date).
Reprex
Expected result
The objects
yand, certainly,xare not affected by callingcolor_values().Actual result
I've been using colourvalues for a year or so and I've never seen any strange behavior like this until now. In scripts, code that worked fine before now has this unexpected side effect. (I noticed it after updating from R 3.6.1 to 3.6.2 and updating packages, though I haven't tried rolling anything back.)