Error in col2rgb(d): error when trying to tween_elements
popovs opened this issue · comments
This error occurs for me when trying to tween multiple map datasets similarly as in this tutorial: https://www.r-graph-gallery.com/a-smooth-transition-between-chloropleth-and-cartogram/
It's also been mentioned on StackOverflow. I'm not sure what's going on, but basically I fixed this by making sure the first column is filled only with numbers. If the first column has strings, the code interprets this as colors for whatever reason.
I am also getting this error, but it doesn't seem to matter whether or not the first column is of a class character. For example, I have the following dataframe:
time y id x ease
1 2013 487888 1 Khyber-Pakhtunkhwa linear
2 2013 495111 2 Khyber-Pakhtunkhwa linear
3 2013 514896 3 Khyber-Pakhtunkhwa linear
4 2013 522307 4 Khyber-Pakhtunkhwa linear
5 2013 439110 5 Khyber-Pakhtunkhwa linear
6 2013 435263 6 Khyber-Pakhtunkhwa linear
Is the problem that the x
variable needs to be of a class numeric or integer?
Can either of you provide a reproducible example? It is not clear to me what code you're running to reach the error, neither is it stated in the linked SO question...
Hi, I was having the same problem.
The problem seems to be when a column isn't a known colour value the check in col_classes()
doesn't return NA, but returns an error, crashing out of the col_classes
function. I replaced this check with a different check (checking the result of a try()
) and this seems to have fixed this particular bug. Can provide a PR if you'd like, but there might be a more elegant solution.