NA as input in aes_string

Viewed 84

I would like to execute the aes_string function also when not providing all variables that are supposed to be defined in aes_string according to my code. The code:

test <- function(data, x, y, c){
    ggplot(data = data, mapping = aes_string(x = x, y = y, colour = c))
}

I would like to be able to execute it also when I do not have any colour variable as input to it, e.g.:

test(data, 'x', 'y', NA)

or

test(data, 'x', 'y', '')

or similar, but I do not know which value I can enter as c for ggplot to not take it into account.

1 Answers
test(data, 'x', 'y', FALSE)

made the job.

Related