Closed SiqiFang closed 3 years ago
Thanks, @SiqiFang. Do you mean the colour comes in as a factor. If so perhaps this is because you are on R 3.6.x. We can try to convert on input.
@SiqiFang noted the following in direct conversation:
The error came from the dataframe colourdf. basically what happened is that inside the function ngl_add_colour(), colour information given in dataframes are then converted to named lists by as.list(setNames(colours[[2]], as.character(colours[[1]]))), after which it is tested if this is a vector. For normal examples, this works fine. However when the colour information is given in terms of characters, e.g. red, green and blue, the df converted to list is no longer a vector, hence the error.
I do currently have R 3.6.x which might be causing the problem.
Bottom line, this appears to be an issue with handling of factors – the default for stringsAsFactors
changed in R4.0.
level is introduced for dfs with colour information is recorded in characters when turning into named list, making its name unrecognisable. See the second example given.