Running examples in ‘tidyquant-Ex.R’ failed
The error most likely occurred in:

> ### Name: geom_bbands
> ### Title: Plot Bollinger Bands using Moving Averages
> ### Aliases: geom_bbands geom_bbands_
> 
> ### ** Examples
> 
> library(dplyr)

######################### Warning from 'xts' package ##########################
#                                                                             #
# The dplyr lag() function breaks how base R's lag() function is supposed to  #
# work, which breaks lag(my_xts). Calls to lag(my_xts) that you type or       #
# source() into this session won't work correctly.                            #
#                                                                             #
# Use stats::lag() to make sure you're not using dplyr::lag(), or you can add #
# conflictRules('dplyr', exclude = 'lag') to your .Rprofile to stop           #
# dplyr from breaking base R's lag() function.                                #
#                                                                             #
# Code in packages is not affected. It's protected by R's namespace mechanism #
# Set `options(xts.warn_dplyr_breaks_lag = FALSE)` to suppress this warning.  #
#                                                                             #
###############################################################################

Attaching package: ‘dplyr’

The following objects are masked from ‘package:xts’:

    first, last

The following objects are masked from ‘package:stats’:

    filter, lag

The following objects are masked from ‘package:base’:

    intersect, setdiff, setequal, union

> library(ggplot2)
> library(lubridate)

Attaching package: ‘lubridate’

The following objects are masked from ‘package:base’:

    date, intersect, setdiff, union

> 
> AAPL <- tq_get("AAPL", from = "2013-01-01", to = "2016-12-31")
Warning: x = 'AAPL', get = 'stock.prices': Error in getSymbols.yahoo(Symbols = "AAPL", env = <environment>, verbose = FALSE, : Unable to import “AAPL”.
Timeout was reached: [query2.finance.yahoo.com] Resolving timed out after 10000 milliseconds

> 
> # SMA
> AAPL %>%
+     ggplot(aes(x = date, y = close)) +
+     geom_line() +           # Plot stock price
+     geom_bbands(aes(high = high, low = low, close = close), ma_fun = SMA, n = 50) +
+     coord_x_date(xlim = c(as_date("2016-12-31") - dyears(1), as_date("2016-12-31")),
+                  ylim = c(20, 35))
Error in `fortify()`:
! `data` must be a <data.frame>, or an object coercible by `fortify()`,
  or a valid <data.frame>-like object coercible by `as.data.frame()`.
Caused by error in `.prevalidate_data_frame_like_object()`:
! `dim(data)` must return an <integer> of length 2.
Backtrace:
     ▆
  1. ├─AAPL %>% ggplot(aes(x = date, y = close))
  2. ├─ggplot2::ggplot(., aes(x = date, y = close))
  3. └─ggplot2:::ggplot.default(., aes(x = date, y = close))
  4.   ├─ggplot2::fortify(data, ...)
  5.   └─ggplot2:::fortify.default(data, ...)
  6.     ├─rlang::try_fetch(...)
  7.     │ ├─base::tryCatch(...)
  8.     │ │ └─base (local) tryCatchList(expr, classes, parentenv, handlers)
  9.     │ │   └─base (local) tryCatchOne(expr, names, parentenv, handlers[[1L]])
 10.     │ │     └─base (local) doTryCatch(return(expr), name, parentenv, handler)
 11.     │ └─base::withCallingHandlers(...)
 12.     └─ggplot2:::validate_as_data_frame(model)
 13.       └─ggplot2:::.prevalidate_data_frame_like_object(data)
 14.         └─cli::cli_abort(paste0("{.code dim(data)} must return ", "an {.cls integer} of length 2."))
 15.           └─rlang::abort(...)
Execution halted