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 running shinyTime Example #8

Closed
ghost opened this issue Jun 14, 2019 · 18 comments
Closed

Error running shinyTime Example #8

ghost opened this issue Jun 14, 2019 · 18 comments
Labels

Comments

@ghost
Copy link

ghost commented Jun 14, 2019

I'm trying to use the code example from the initial page of shinyTime but I'm getting errors

library(shiny) library(shinyTime) ui <- fluidPage( timeInput("time1", "Time:"), timeInput("time2", "Time:", value = Sys.time()), timeInput("time3", "Time:", value = strptime("12:34:56", "%T")), timeInput("time4", "Time:", seconds = FALSE), timeInput("time5", "Time:", minute.steps = 5) ) server <- function(input, output) { observe(print(strftime(input$time1, "%T"))) observe(print(strftime(input$time4, "%R"))) } shinyApp(ui,server)

I'm getting this message after running the code:

Listening on http://127.0.0.1:3378 Warning: Error in as.POSIXlt.default: do not know how to convert 'x' to class “POSIXlt” [No stack trace available] Warning: Error in as.POSIXlt.default: do not know how to convert 'x' to class “POSIXlt” [No stack trace available]

Can you help me with this?

@burgerga
Copy link
Owner

burgerga commented Jun 14, 2019

Hi @Raphael04, for me your code is running without errors...
Does shinyTime::shinyTimeExample() work for you?

EDIT: and can you show me your sessionInfo()?

@ghost
Copy link
Author

ghost commented Jun 14, 2019

  • Session info -----------------------------------------------------------------------------------------------------------------------------
    setting value
    version R version 3.5.1 (2018-07-02)
    os Windows 7 x64 SP 1
    system x86_64, mingw32
    ui RStudio
    language (EN)
    collate Portuguese_Brazil.1252
    ctype Portuguese_Brazil.1252
    tz America/Sao_Paulo
    date 2019-06-14

  • Packages ---------------------------------------------------------------------------------------------------------------------------------
    ! package * version date lib source
    assertthat 0.2.1 2019-03-21 [1] CRAN (R 3.5.3)
    backports 1.1.4 2019-04-10 [1] CRAN (R 3.5.3)
    callr 3.2.0 2019-03-15 [1] CRAN (R 3.5.3)
    cli 1.1.0 2019-03-19 [1] CRAN (R 3.5.3)
    crayon 1.3.4 2017-09-16 [1] CRAN (R 3.5.3)
    curl 3.3 2019-01-10 [1] CRAN (R 3.5.3)
    desc 1.2.0 2018-05-01 [1] CRAN (R 3.5.3)
    devtools * 2.0.2 2019-04-08 [1] CRAN (R 3.5.3)
    R digest 0.6.18 [1]
    fs 1.3.1 2019-05-06 [1] CRAN (R 3.5.3)
    glue 1.3.1 2019-03-12 [1] CRAN (R 3.5.3)
    htmltools 0.3.6 2017-04-28 [1] CRAN (R 3.5.3)
    httpuv 1.5.1 2019-04-05 [1] CRAN (R 3.5.3)
    jsonlite 1.6 2018-12-07 [1] CRAN (R 3.5.3)
    later 0.8.0 2019-02-11 [1] CRAN (R 3.5.3)
    magrittr 1.5 2014-11-22 [1] CRAN (R 3.5.3)
    memoise 1.1.0 2017-04-21 [1] CRAN (R 3.5.3)
    mime 0.6 2018-10-05 [1] CRAN (R 3.5.2)
    pkgbuild 1.0.3 2019-03-20 [1] CRAN (R 3.5.3)
    pkgload 1.0.2 2018-10-29 [1] CRAN (R 3.5.3)
    prettyunits 1.0.2 2015-07-13 [1] CRAN (R 3.5.3)
    processx 3.3.1 2019-05-08 [1] CRAN (R 3.5.3)
    promises 1.0.1 2018-04-13 [1] CRAN (R 3.5.3)
    ps 1.3.0 2018-12-21 [1] CRAN (R 3.5.3)
    R6 2.4.0 2019-02-14 [1] CRAN (R 3.5.3)
    Rcpp 1.0.1 2019-03-17 [1] CRAN (R 3.5.3)
    remotes 2.0.4 2019-04-10 [1] CRAN (R 3.5.1)
    rlang 0.3.4 2019-04-07 [1] CRAN (R 3.5.3)
    rprojroot 1.3-2 2018-01-03 [1] CRAN (R 3.5.3)
    rsconnect 0.8.13 2019-01-10 [1] CRAN (R 3.5.3)
    rstudioapi 0.10 2019-03-19 [1] CRAN (R 3.5.3)
    sessioninfo 1.1.1 2018-11-05 [1] CRAN (R 3.5.3)
    shiny * 1.3.2 2019-04-22 [1] CRAN (R 3.5.3)
    shinyTime * 1.0.0 2019-05-28 [1] CRAN (R 3.5.3)
    testthat 2.1.1 2019-04-23 [1] CRAN (R 3.5.3)
    usethis * 1.5.0 2019-04-07 [1] CRAN (R 3.5.3)
    withr 2.1.2 2018-03-15 [1] CRAN (R 3.5.3)
    xtable 1.8-4 2019-04-21 [1] CRAN (R 3.5.3)
    yaml 2.2.0 2018-07-25 [1] CRAN (R 3.5.2)

[1] D:/Pessoal/R/win-library/3.5
[2] C:/Program Files/R/R-3.5.1/library

R -- Package was removed from disk.

@ghost
Copy link
Author

ghost commented Jun 14, 2019

When I run shinyTime::shinyTimeExample() I get this:

image

@burgerga burgerga added the bug label Jun 14, 2019
burgerga added a commit that referenced this issue Jun 14, 2019
- Avoids problems with Internet Explorer
- Fixes #8
@burgerga
Copy link
Owner

burgerga commented Jun 14, 2019

It seems I used some javascript that is incompatible with older browsers, can you test my proposed solution using

if (!require("pacman")) install.packages("pacman"); library(pacman)
p_load_gh('burgerga/shinyTime@fix/gh8')
shinyTimeExample()

Much appreciated!

@ghost
Copy link
Author

ghost commented Jun 17, 2019

Hi,

Unfortunately, I'm getting the same error.

How can I help you to investigate what is going on?

=)

@burgerga
Copy link
Owner

burgerga commented Jun 17, 2019

Ah that is unfortunate :(
Do you have the same issue when running it in a browser? (If so, can you open the developer tools and look at the console to see javascrapt error messages?)

@ghost
Copy link
Author

ghost commented Jun 17, 2019

Interesting point. When I ran the app with Browser (Google Chrome), Everything went ok..

@burgerga
Copy link
Owner

Yes, I'm trying to figure out which browser your RStudio is using. On my pc I had a problem with Internet Explorer but I thought I fixed that with f843ce8...

@ghost
Copy link
Author

ghost commented Jun 17, 2019

Just got this:

getOption("browser")
function (url)
{
.Call("rs_browseURL", url)
}
<environment: 0x000000000a360f10>

@burgerga
Copy link
Owner

Can you try browseURL("https://www.google.com")?

@ghost
Copy link
Author

ghost commented Jun 17, 2019

Rstudio redirected to Chrome

@burgerga
Copy link
Owner

Hmm, that it's working in Chrome means that most likely this is a javascript issue...
I have run a linter on my js, and discovered that I introduced some lets (ES6) instead of vars.
Can you try the new fix?

p_load_current_gh('burgerga/shinyTime@fix/gh8')
shinyTimeExample()

@ghost
Copy link
Author

ghost commented Jun 17, 2019

I'm getting a warning running the p_load:

pacman::p_load_current_gh('burgerga/shinyTime@fix/gh8') Warning message: In p_install_gh(package, dependencies = dependencies, ...) : The following may have incorrect capitalization specification: shinyTime

After that, Nothing has changed when running shinyTimeExample (Working in Browser, error in Rstudio)

@burgerga
Copy link
Owner

That is strange...
So it might not have been installed.
Can you check the following:

  1. Run the example in Chrome
  2. Press F12 to open Developer tools
  3. Go the network tab
  4. Press Ctrl+R to relead
  5. Click input_binding_time.js and open the Response tab
  6. Check the roundTime function (should be on line 48)

image

Does it look like this:

// From https://stackoverflow.com/a/48512262/1439843
var roundTime = function(value, minutesToRound) {

  var roundTimeDate = function(date) {
    var ms = 1000 * 60 * minutesToRound; // convert minutes to ms
    return new Date(Math.round((new Date(date)).getTime() / ms) * ms);
  };

  roundedDate = roundTimeDate((new Date()).setHours(value.hour, value.min, value.sec));
  return {hour: zeroPad(roundedDate.getHours()), min: zeroPad(roundedDate.getMinutes()), sec: zeroPad(roundedDate.getSeconds())};
};

or does it have lets?

@ghost
Copy link
Author

ghost commented Jun 18, 2019

I found lets in that version..

var roundTime = function(value, minutesToRound) { let roundTimeDate = function(date) { let ms = 1000 * 60 * minutesToRound; // convert minutes to ms return new Date(Math.round((new Date(date)).getTime() / ms) * ms); }; roundedDate = roundTimeDate((new Date()).setHours(value.hour, value.min, value.sec)); return {hour: zeroPad(roundedDate.getHours()), min: zeroPad(roundedDate.getMinutes()), sec: zeroPad(roundedDate.getSeconds())}; };

@burgerga
Copy link
Owner

Ahhh, then my latest changes were not included, because of the failed update

Can you try

p_delete("shinyTime")
p_load_current_gh('burgerga/shinyTime@fix/gh8')
shinyTimeExample()

This will delete the currently installed shinyTime so hopefully then the installation will succeed :)

@ghost
Copy link
Author

ghost commented Jun 18, 2019

Now, everything is working =)

Thanks so much!

@burgerga
Copy link
Owner

No problem, thanks for taking the time to report the issue and for your patience :)

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

No branches or pull requests

1 participant