Shiny Get Started - Lesson 6 Use Reactive Expressions may need updating?

I'm working through the 'Get Started' tutorials on the R Shiny website, however having problems with Lesson 6: https://shiny.rstudio.com/tutorial/written-tutorial/lesson6/

Packages used here are shiny (version 1.1.0) and quantmod (version 0.4-13)

The server part of the app contains the following code:

server <- function(input, output) {
dataInput <- reactive({
getSymbols(input$symb, src = "google",
from = input$dates[1],
to = input$dates[2],
auto.assign = FALSE)
})

Running this app results in the error:
''getSymbols.google' is defunct. Google Finance stopped providing data in March 2018. You could try setting src = "yahoo" instead'

So I set src="yahoo", saved and re ran.

I then got this error:
Timeout was reached:Connection timed out after 10000 milliseconds.

Please can someone advise?

Many thanks in advance, Liz

2 Likes

Thanks for letting us know!

In line 42 of your app.R, replace "google" with "yahoo"

So the getSymbols call should now look like;

    getSymbols(input$symb, src = "yahoo",  
               from = input$dates[1],
               to = input$dates[2],
               auto.assign = FALSE)

Thank you for you quick response, I re ran the code as suggested but received this error message:

‘Error: Timeout was reached: Connection timed out after 10015 milliseconds’

Any chance you have a proxy that prevents your shiny app from connecting to yahoo?

For example, on the same machine as your shiny server, can you run the following

library(dplyr)
library(quantmod)
mydata <- getSymbols("SPY", 
           src = "yahoo",  
           from = "2013-01-01",
           to = "2013-01-31",
           auto.assign = FALSE) %>% 
  tbl_df()
#> 'getSymbols' currently uses auto.assign=TRUE by default, but will
#> use auto.assign=FALSE in 0.5-0. You will still be able to use
#> 'loadSymbols' to automatically load data. getOption("getSymbols.env")
#> and getOption("getSymbols.auto.assign") will still be checked for
#> alternate defaults.
#> 
#> This message is shown once per session and may be disabled by setting 
#> options("getSymbols.warning4.0"=FALSE). See ?getSymbols for details.
#> 
#> WARNING: There have been significant changes to Yahoo Finance data.
#> Please see the Warning section of '?getSymbols.yahoo' for details.
#> 
#> This message is shown once per session and may be disabled by setting
#> options("getSymbols.yahoo.warning"=FALSE).
mydata %>% head()
#> # A tibble: 6 x 6
#>   SPY.Open SPY.High SPY.Low SPY.Close SPY.Volume SPY.Adjusted
#>      <dbl>    <dbl>   <dbl>     <dbl>      <dbl>        <dbl>
#> 1     145.     146.    145.      146.  192059000         130.
#> 2     146.     146.    145.      146.  144761800         130.
#> 3     146.     147.    146.      146.  116817700         131.
#> 4     146.     146.    145.      146.  110002500         130.
#> 5     146.     146.    145.      146.  121265100         130.
#> 6     146.     146.    146.      146.   90745600         130.

Created on 2018-12-19 by the reprex package (v0.2.1)

I am running this code on a work laptop so there is a chance the code has been blocked. On running the code suggested in a normal R script I get this message in the console:

Loading required package: TTR
Version 0.4-0 included new data defaults. See ?getSymbols.
Learn from a quantmod author: https://www.datacamp.com/courses/importing-and-managing-financial-data-in-r

mydata <- getSymbols("SPY",

  •                  src = "yahoo",  
    
  •                  from = "2013-01-01",
    
  •                  to = "2013-01-31",
    
  •                  auto.assign = FALSE) %>% 
    
  • tbl_df()
    ‘getSymbols’ currently uses auto.assign=TRUE by default, but will
    use auto.assign=FALSE in 0.5-0. You will still be able to use
    ‘loadSymbols’ to automatically load data. getOption("getSymbols.env")
    and getOption("getSymbols.auto.assign") will still be checked for
    alternate defaults.

This message is shown once per session and may be disabled by setting
options("getSymbols.warning4.0"=FALSE). See ?getSymbols for details.

WARNING: There have been significant changes to Yahoo Finance data.
Please see the Warning section of ‘?getSymbols.yahoo’ for details.

This message is shown once per session and may be disabled by setting
options("getSymbols.yahoo.warning"=FALSE).
Error in curl::curl_download(cu, tmp, handle = h) :
Timeout was reached: Connection timed out after 10015 milliseconds

This particular learning module does require the ability to connect to yahoo finance to get these prices and your error message suggests to me that the work network is preventing that connection, resulting in the timeout error.
(I might be wrong there.)

A few options:

  • ask your IT folks if they might have a proxy they would prevent this, and for advice
  • try these lesions on a different network.
  • check out the later course modules until you’ve got this resolved.

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.