Error in gsub("&", "&", result, fixed = TRUE) : input string 1 is invalid in this locale

1,367 views
Skip to first unread message

Mavis

unread,
Aug 11, 2014, 5:07:17 AM8/11/14
to shiny-...@googlegroups.com
Hi everyone,

A few weeks ago, my code worked well. but today it gives me error like this:
Error in gsub("&", "&", result, fixed = TRUE) : 
  input string 1 is invalid in this locale

In my code, I want to catch the table from yahoo :

# Make competitorTable
makecompetitorTable <- reactive(function() {    
  tryCatch({
    # download competitor from yahoo
    ur5 = paste('http://finance.yahoo.com/q/co?s=', input$symb, sep = '')
    txt5 = join(readLines(ur5))
    
    # extract Valuation Measures table from this page
    temp5 = extract.table.from.webpage(txt5, 'Market Cap', hasHeader = T)
 
    temp5
  }, error = function(e) { stop(paste('Problem getting Key Statistics for',input$symb)) })
})

# Generate a table
output$competitorTable <- reactive(function() {
  temp5 = makecompetitorTable()  
  tableColor(as.matrix(temp5),include.rownames=FALSE)  
})


I am very new to shiny and I hope you can help me. Thank you!

Yihui Xie

unread,
Aug 20, 2014, 12:02:05 AM8/20/14
to Mavis, shiny-discuss
Have you upgraded your packages to their latest versions? If not,
please run update.packages(ask = FALSE), otherwise please send us a
minimal and complete example along with the output of
library(shiny);sessionInfo().

BTW, I'm a little surprised that you said you were new to shiny but
you were still using the very old and deprecated syntax
reactive(function() { expr }) instead of reactive({ expr }). You
should see a warning like this when you use the former syntax:

Passing functions to 'reactive' is deprecated. Please use
expressions instead. See ?reactive for more information.

I'm wondering where you learned the deprecated syntax, and we should
definitely fix it if it is still on our website (shiny.rstudio.com).

Regards,
Yihui
Reply all
Reply to author
Forward
0 new messages