0

I have the problem with the ggplot.

The data samples:

> data
[1] "KemData"
> depVal
[1] "Урожайность т/га"
> facVal1
[1] "Предшествующая культура"

When I try to build a plot with the following parameters:

ggplot(get(data), aes(fill=as.name(depVal), y=as.name(depVal), x=Год))

It gives me the following error:

 Don't know how to automatically pick scale for object of type name. Defaulting to continuous.
    Error: Aesthetics must be valid data columns. Problematic aesthetic(s): y = as.name(depVal), fill = as.name(depVal).

But if I avoid using as.name, then ggplot won't work with double quotes as an input.

I also tried to replace quotes with gsub but it doesn't seem to work

  • 1
    Try with e.g `fill = .data[[depVal]]` using the `.data` pronoun from `rlang`. – stefan Jun 23 '21 at 08:55
  • `aes_string()` or even `aes_()` rather than `aes()` is probably what you're looking for - see the examples in `?aes` – Miff Jun 23 '21 at 08:55

0 Answers0