Skip to content

[R-pkg-devel] Rlang and Code Evalutation Within Aesthetics

3 messages · Dario Strbenac, Duncan Murdoch, Jeff Newmiller

#
Good day,

I am troubled understanding why the following example doesn't work:
$x
`Classifier Name`
Error in `rlang::sym()`:
! Can't convert NULL to a symbol.
10. rlang::sym(characteristicsList[["fillColour"]])

but the following does work without error:
NULL # It is desirably avoiding the else part.

The first example seems to be evaluating the else part, even though the if condition is true.

The overall aim is to allow the end-user to specify a named list of appearance-modifying parameters, and for the function to create a ggplot with them, without being bamboozled if the end-user's list doesn't contain the specification for fill colour variable name or line colour variable name (like the list in the example above does not have). Thanks in advance for any suggested reading.

--------------------------------------
Dario Strbenac
University of Sydney
Camperdown NSW 2050
Australia
#
On 30/04/2022 8:00 a.m., Dario Strbenac wrote:
I'm pretty sure this isn't the right place to ask about ggplot2, but 
that looks like a bug to me.

Duncan Murdoch
#
Things like sensible legends are also impeded by using complex expressions in aesthetics mappings, so call it a workaround if you like but creating the data frame the way it should be _before_ giving it to ggplot has always been recommended.
On April 30, 2022 5:09:51 AM PDT, Duncan Murdoch <murdoch.duncan at gmail.com> wrote: