1

I am trying to run a shiny app including a rpivottable.

my config: devtools 1.8.0, htmlwidgets 0.4.2, rpivotTable 0.1.4.1, shiny 0.12.0

R version 3.1.2 (2014-10-31)

Ubuntu 14.04.1 LTS

My code works perfectly locally, but crash on the server. On the browser, I get this error on the console:

TypeError: x is undefined

And it links to this code:

HTMLWidgets.widget({

    name: 'rpivotTable',

    type: 'output',

    initialize: function(el, width, height) {

        return {}

    },

    renderValue: function(el, x, instance) {
        x.data = HTMLWidgets.dataframeToD3(x.data);

        var derivers = $.pivotUtilities.derivers;
      var tpl = $.pivotUtilities.aggregatorTemplates;

      x.params.renderers = $.extend(
        $.pivotUtilities.renderers,
        $.pivotUtilities.d3_renderers,
        $.pivotUtilities.c3_renderers
      );


      $('#'+el.id).pivotUI(
            x.data, x.params
      );

    },

    resize: function(el, width, height, instance) {

    }

});

My R code is the following:

if (interactive()) {  lib.path <- my.path.local
} else {  lib.path <- my.path.server }

### packages ###
library(shiny, lib.loc =  lib.path)
library(htmlwidgets, lib.loc = lib.path)
library(rpivotTable, lib.loc = lib.path)

data <- data.frame(var1 = c("mod1", "mod2"), value = c(1, 2))

shinyApp(
  ui =  fluidPage(
    sidebarLayout(
      sidebarPanel(
    textOutput("config"),  textOutput("path"), textOutput("version"))
    , mainPanel(
     rpivotTableOutput("test")
    )
    )), 

  server = function(input, output) {
       output$test <- rpivotTable::renderRpivotTable({
         rpivotTable(data = data)
       })

    output$config <- renderText({ 
      tt <- installed.packages()
     paste(paste(tt[tt[, 1] %in% c("shiny", "htmlwidgets", "rpivotTable", "devtools") , 1], 
                tt[tt[, 1] %in% c("shiny", "htmlwidgets", "rpivotTable", "devtools") , 3]), collapse = ", ")
    })

    output$path <- renderText({ 
      ll <- .libPaths()
      ll
    })

    output$version <- renderText({ 
      ss <- sessionInfo()
      ss[[1]]$version.string
    })

  }
)

does anybody already met this error?

best,

nicolaskruchten
  • 26,384
  • 8
  • 83
  • 101
YCR
  • 3,794
  • 3
  • 25
  • 29
  • I found the issue: It is most likely a RAM problem. I upgraded my AWS version from t2.micro to t2.small and it works fine. – YCR Jun 01 '15 at 11:31

2 Answers2

1

the example is functional.

better written:

library(shiny)
library(rpivotTable)

data <- data.frame(var1 = c("mod1", "mod2"), value = c(1, 2))

shinyApp(
  ui =  fluidPage(
    sidebarLayout(
      sidebarPanel(mainPanel(
     rpivotTableOutput("test")
    )
    )), 

  server = function(input, output) {
       output$test <- rpivotTable::renderRpivotTable({
         rpivotTable(data = data)
       })

  }
)
YCR
  • 3,794
  • 3
  • 25
  • 29
-3

YCR: Don't have a comment but do you have a working example of a Shiny + rpivotTable to share?

Actually - THIS IS A WORKING example.

Thanks for sharing.

revert
  • 49
  • 3