I have the problem that a simple script for plotting does run in command but no in RStudio. I even can't figure out where the problem is:
library(tidyverse)
library(tidyquant)
library(ggplot2)
options("getSymbols.warning4.0"=FALSE)
options("getSymbols.yahoo.warning"=FALSE)
AAPL = tq_get(x="AAPL")
AAPL %>%
ggplot( aes(x = date, y = close)) +
geom_line() +
labs(title = "Aktienkurs", y = "Schlusskurs", x = "") +
theme_tq()
In R console mode there is no problem and the Grafik shows up. In RStudio it is not, the error is:
Don't know how to automatically pick scale for object of type function. Defaulting to continuous.
Don't know how to automatically pick scale for object of type function. Defaulting to continuous.
Fehler: Aesthetics must be valid data columns. Problematic aesthetic(s): x = date, y = close.
Did you mistype the name of a data column or forget to add after_stat()?
And if I change the command to:
library(tidyverse)
library(tidyquant)
library(ggplot2)
options("getSymbols.warning4.0"=FALSE)
options("getSymbols.yahoo.warning"=FALSE)
AAPL = tq_get(x="AAPL")
ggplot(data=AAPL, aes(x = date, y = close)) +
geom_line() +
labs(title = "Aktienkurs", y = "Schlusskurs", x = "") +
theme_tq()
The same error. If I fetch the error with:
rlang::last_error()
<error/rlang_error>
Aesthetics must be valid data columns. Problematic aesthetic(s): x = date, y = close.
Did you mistype the name of a data column or forget to add after_stat()?
Backtrace:
1. (function (x, ...) ...
2. ggplot2:::print.ggplot(x)
4. ggplot2:::ggplot_build.ggplot(x)
5. ggplot2:::by_layer(function(l, d) l$compute_aesthetics(d, plot))
6. ggplot2:::f(l = layers[[i]], d = data[[i]])
7. l$compute_aesthetics(d, plot)
8. ggplot2:::f(..., self = self)
Run `rlang::last_trace()` to see the full context.
And if I run
rlang::last_trace()
<error/rlang_error>
Aesthetics must be valid data columns. Problematic aesthetic(s): x = date, y = close.
Did you mistype the name of a data column or forget to add after_stat()?
Backtrace:
█
1. ├─(function (x, ...) ...
2. └─ggplot2:::print.ggplot(x)
3. ├─ggplot2::ggplot_build(x)
4. └─ggplot2:::ggplot_build.ggplot(x)
5. └─ggplot2:::by_layer(function(l, d) l$compute_aesthetics(d, plot))
6. └─ggplot2:::f(l = layers[[i]], d = data[[i]])
7. └─l$compute_aesthetics(d, plot)
8. └─ggplot2:::f(..., self = self)
I know that I am missing something but I just can't figure it out...