Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error in as.character: cannot coerce type 'closure' to vector of type 'character' #20

Open
englianhu opened this issue May 4, 2016 · 1 comment

Comments

@englianhu
Copy link

Below is the error :
http://stackoverflow.com/questions/36988554/vector-error-multiple-stocks-by-using-quantmod-on-shiny-web-application

And then I tried to get the relevant functions and using Rmarkdown to test the origin of error...

library(shiny)

createNonReactiveTextInput <- function(id, label, value, 
                                       button.label = '') {

  value = lapply(value, as.character)

  if(button.label != '')
    list(
      tagList(
        tags$label(label), tags$input(id = id, type = "text", value = value, 
                                      style = "display:none;"), 
        tags$input(id = paste(id, "Temp", sep=''), type = "text", 
                   value = value, style = "display:inline;", 
                   onkeypress = paste("{if (event.keyCode==13) $('#", id, 
                                      "TempChange').click()}", sep = ''))), 
      div(
        tags$button(id = paste(id, "TempChange", sep=''), type = "button", 
                    class = "btn btn-primary", onclick = paste("$('#", id, 
                                                               "').val($('#", id, "Temp').val()).change();", 
                                                               sep = ''), button.label)))
  else
    list(
      tagList(
        tags$label(label), tags$input(id = id, type = "text", value = value, 
                                      style = "display:none;"), 
        tags$input(id = paste(id, "Temp", sep = ''), type = "text", 
                   value = value, style = "display:inline;", 
                   onkeypress = paste("{if (event.keyCode==13) $('#", id, 
                                      "').val($('#", id, 
                                      "Temp').val()).change()}", 
                                      sep = ''))))
}

createNonReactiveTextInputCustom <- function(id, label, tag.label = 'input', 
                                             button.label = '', 
                                             enableEnter = TRUE, opts) {
  onkeypress = ''
  if(button.label != '') {
    if(enableEnter)
      onkeypress = paste("{if (event.keyCode==13) $('#", id, 
                         "TempChange').click()}", sep = '')

    list(tagList(tags$label(label), 
                 tag(tag.label, c(id = id, style = "display:none;", opts)), 
                 tag(tag.label, c(id = paste(id, "Temp", sep = ''), 
                                  style = "display:inline;", 
                                  onkeypress = onkeypress, opts))),
         div(
           tags$button(id = paste(id, "TempChange", sep = ''), 
                       type = "button", class = "btn btn-primary", onclick = 
                         paste("$('#", id, "').val($('#", id, 
                               "Temp').val()).change();", sep = ''), 
                       button.label)))
  } else {
    if(enableEnter)
      onkeypress = paste("{if (event.keyCode==13) $('#", id, 
                         "').val($('#", id, 
                         "Temp').val()).change()}", sep = '')
    list(
      tagList(
        tags$label(label), tag(tag.label, c(id = id, style = 
                                              "display:none;", opts)), 
        tag(tag.label, c(id = paste(id,"Temp", sep = ''), 
                         style = "display:inline;", 
                         onkeypress = onkeypress, opts))))
  }
}
input = ls()
createNonReactiveTextInput(
          id = "symbols", 
          label = "Yahoo Ticker(s) separated by comma:", 
          value = "AAPL,GOOG", button.label = "Update")
str(input$symbols)

and the system prompt me below error message, I believed that is because of the createNonReactiveTextInput() and input$symbols doesn't work properly with the shiny input$xxx. Would you look into this? Thank you.

- Quitting from lines 88-89 (test2.Rmd) 
- Error in input$symbols : $ operator is invalid for atomic vectors
- Calls: <Anonymous> ... withCallingHandlers -> withVisible -> eval -> eval -> str
- Execution halted

Shiny version :

> devtools::session_info()$platform
 setting  value                       
 version  R version 3.2.3 (2015-12-10)
 system   x86_64, linux-gnu           
 ui       RStudio (0.99.896)          
 language (EN)                        
 collate  en_US.UTF-8                 
 tz       GMT                         
 date     2016-05-04
englianhu added a commit to scibrokes/analyse-the-finance-and-stocks-price-of-bookmakers that referenced this issue May 4, 2016
remarks :
1) app.R inside test5 test the createNonReactiveTextInput() due to #issue systematicinvestor/SIT#20 while test3 stored the completed shiny app
@englianhu
Copy link
Author

englianhu commented May 11, 2016

test with windows with latest version shiny and ®Studio but similar error.

- Warning: Error in as.character: cannot coerce type 'closure' to vector of type 'character'
Stack trace (innermost first):
    82: tagList
    81: as.tags.default
    80: as.tags
    79: inherits
    78: isTag
    77: rewriteTags
    76: tagify
    75: func
    74: rewriteTags
    73: tagify
    72: htmlDependencies
    71: findDependencies
    70: resolveDependencies
    69: lapply
    68: output$status
     1: shiny::runApp

> packageVersion('shiny')
[1] ?.13.2.9003?
> devtools::session_info()$platform
Session info ----------------------------------------------------------------------------------------
 setting  value                       
 version  R version 3.3.0 (2016-05-03)
 system   x86_64, mingw32             
 ui       RStudio (0.99.1130)         
 language (EN)                        
 collate  English_United States.1252  
 tz       GMT                         
 date     2016-05-11

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant