Git Product home page Git Product logo

rpivottable's Introduction

rpivotTable: pivottable for R

The rpivotTable package is an R htmlwidget visualization library built around the Javascript pivottable library.

PivotTable.js is a Javascript Pivot Table library with drag'n'drop functionality built on top of jQuery/jQueryUI and written in CoffeeScript (then compiled to JavaScript) by Nicolas Kruchten at Datacratic. It is available under an MIT license

Installation

The rpivotTable package depends on htmlwidgets package so you need to install both packages. You can do this using the devtools package as follows:

devtools::install_github(c("ramnathv/htmlwidgets", "smartinsightsfromdata/rpivotTable"))

Usage

Call the package with

library(rpivotTable)  # No need to explicitly load htmlwidgets: this is done automatically

Just plug in your data.frame or data.table (e.g. dt) to rpivotTable().

It is as simple as this:

data(mtcars)
rpivotTable(mtcars)

The pivot table should appear in your RStudio Viewer or your browser of choice.

Please refer to the examples and explanations here.

rpivotTable parameters decide how the pivot table will look like the firs time it is opened:

  • data can be a data.frame or data.table. Nothing else is needed. If only the data is selected the pivot table opens with nothing on rows and columns (but you can at any time drag and drop any variable in rows or columns at your leasure)
  • rows and cols allow the user to create a report, i.e. to indicate which element will be on rows and columns.
  • aggregatorName indicates the type of aggregation. Options here are numerous: Count, Count Unique Values, List Unique Values, Sum, Integer Sum, Average, Sum over Sum, 80% Upper Bound, 80% Lower Bound, Sum as Fraction of Total, Sum as Fraction of Rows, Sum as Fraction of Columns, Count as Fraction of Total, Count as Fraction of Rows, Count as Fraction of Columns
  • vals specifies the variable to use with aggregatorName.
  • renderers dictates the type of graphic element used for display, like Table, Treemap etc.
  • sorters allow to implement a javascript function to specify the ad hoc sorting of certain values. See vignette for an example. It is especially useful with time divisions like days of the week or months of the year (where the alphabetical order does not work)
  • subtotals will allow to dynamically select / deselect subtotals

For example, to display a pivot table with frequency of colour combinations of eyes and hair, you can specify:

data(HairEyeColor)
rpivotTable(data = HairEyeColor, rows = "Hair",cols="Eye", vals = "Freq", aggregatorName = "Sum", rendererName = "Table", width="100%", height="400px")

This will display a cross tab with the frequency of eyes by hair colour. Dragging & dropping (slicing & dicing) categorical variables in rows and columns changes the shape of the table.

If you want to include it as part of your dplyr / magrittr pipeline, you can do that also:

library(dplyr)
iris %>%
  tbl_df() %>%
  filter( Sepal.Width > 3 ) %>%
  rpivotTable()

Latest news

I'm happy to announce that Nicolas Kruchten has officialy joined the rpivotTable project. Many thanks to him for the work on the current release.

rpivottable's People

Contributors

enzo-dt avatar garthtarr avatar jcizel avatar nicolaskruchten avatar palatinuse avatar renkun-ken avatar smartinsightsfromdata avatar timelyportfolio avatar wibeasley avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

rpivottable's Issues

height and width parameters

are these active in rpivotTableOutput? They don't seem to make a difference. Is there another way to control the size of the table?

Shiny: Change in radioButtons does not refresh/update the rpivotTable

I am trying to use shiny::radioButtons to update/refresh a pivot table (i.e. change initial rows/columns/variables setting), but that doesn't seem to be working.

In the below shiny app, when you change the input based on radioButtons it does not get reflected in the rpivotTable output. It stays the same regardless.

Do you know if there's anything wrong in this code? or is it even possible to achieve such a functionality?

Code:

library(shiny)
library(magrittr)
library(rpivotTable)

# based on radio button selection selects the list with specific parameter types
pivot_switch_fn <- function(l_in, type) {
  switch(type,
         choice1 = l_in$l1,
         choice2 = l_in$l2)
}


d_in = data.frame(grp_var1 = rep(letters[1:5], times = 6),
                  grp_var2 = rep(letters[6:8], times = 10),
                  grp_var3 = rep(letters[9:10], times = 15),
                  metric1 = sample.int(n = 100, size = 30),
                  metric2 = sample.int(n = 100, size = 30),
                  metric3 = sample.int(n = 100, size = 30))

l1 = list(l_rows = "grp_var1", 
          l_cols = "grp_var2", 
          l_val = "metric1",
          l_aggregatorName = "Sum",
          l_rendererName = "Table")

l2 = list(l_rows = "grp_var2", 
          l_cols = "grp_var1", 
          l_val = "metric2",
          l_aggregatorName = "Count",
          l_rendererName = "Table Barchart")

l_in = list(l1 = l1, 
            l2 = l2)

rb_levels = list(`Choice 1` = "choice1",
                 `Choice 2` = "choice2")

server = function(input, output) {

  output$pivot_setting_rb = renderUI({
    radioButtons(inputId = "pivot_setting", label = "Shortcuts", 
                 choices  = rb_levels)
  })

  output$test <- rpivotTable::renderRpivotTable({
    print(input$pivot_setting)
    ls = pivot_switch_fn(l_in, input$pivot_setting)
    print(ls)

    ls %$%
      rpivotTable(data = d_in, 
                  rows = l_rows,
                  cols = l_cols,
                  val = l_val,
                  aggregatorName = l_aggregatorName,
                  rendererName = l_rendererName)

  })
}

ui =  fluidPage(
  uiOutput("pivot_setting_rb"), br(),br(),br(),
  rpivotTableOutput("test")
) 


shinyApp(ui = ui, server = server, options = list(height = '3000px', width = '100%'))

Can't Install using Rstudio on PC running Windows 7

Can you help please.

I can't install rpivotTable on a windows 7 pc (RStudio Version 0.99.447).

Here is the output I get:

Installing htmlwidgets
Installing 1 packages: yaml
package ‘yaml’ successfully unpacked and MD5 sums checked
"C:/Program Files/R/R-32~1.1/bin/x64/R" --no-site-file --no-environ --no-save --no-restore CMD
INSTALL
"C:/Users/PK/AppData/Local/Temp/RtmpCEscPS/devtoolse6834c7b67/ramnathv-htmlwidgets-955ddc0"
--library="C:/Users/PK/Documents/R/win-library/3.2" --install-tests

'C:\Program' is not recognized as an internal or external command,
operable program or batch file.
Error: Command failed (1)

install_github("smartinsightsfromdata/rpivotTable")
Downloading github repo smartinsightsfromdata/rpivotTable@master
Installing rpivotTable
Installing 1 packages: htmlwidgets
package ‘htmlwidgets’ successfully unpacked and MD5 sums checked
"C:/Program Files/R/R-32~1.1/bin/x64/R" --no-site-file --no-environ --no-save --no-restore CMD
INSTALL
"C:/Users/PK/AppData/Local/Temp/RtmpCEscPS/devtoolse682da67e74/smartinsightsfromdata-rpivotTable-89fcddf"
--library="C:/Users/PK/Documents/R/win-library/3.2" --install-tests

'C:\Program' is not recognized as an internal or external command,
operable program or batch file.
Error: Command failed (1)

Thanks in advance
PK

New project proposal

This is a proposal for all interested parties, but especially @jrowen, @timelyportfolio & @nicolaskruchten to see if this proposal may wet their appetite.

We have a decent pivottable widget with rpivotTable, based on pivottable.js

I recently discovered that there is a custom project based on pivottable.js, that introduces handsontable as the base table, and highchart.

The NovixPivotJS project is currently possibly abandoned, but it represents undoubtedly an advance.

The main advantages of NovixPivotJS vs. pivottable are:

  • the table has vertical and horizontal scrollers. This overcome one perceived limitation of pivottable: it is too dynamic. The presence of scroll bars would make it an ideal widget for jupyter (in R and Python) and shiny.
  • handsontable is a step improvement over existing table
  • it is possible to enter data into the pivottable (i.e. in handsontable)

On the other hand the complexity of handling data entry, well familiar to @jrowen (and to me with my early experiments on handsontable), and the introduction ofhighchartrepresent a level of complexity well beyond my meagre javascript skills. There would be also the additional core of maintaining alignment withpivottable`.

A team effort would seems a good way forward, sort of bringing together some elements of rhandsontable and rpivottable (both packages would continue to make sense as specialised versions).

In an ideal world this would require:

  • @nicolaskruchten to integrate NovixPivotJS and maintain it in parallel to pivottable evolutions
  • @jrowen to lend his expertise (and code) to make the data entry function work in R and in shiny
  • @timelyportfolio to lend an hand
  • @smartinsightsfromdata (me) to make as less of a mess as possible of any code
  • any interested party to help

Does it sound feasible and worth the effort?

Default installation doesn't work with browser path on Linux

Example to run

library(rpivotTable)
data(mtcars)
rpivotTable(mtcars)

Error

Unable to load page
Problem occurred while loading the URL http://tmp/RtmpcvwPCH/viewhtml4a5376c24e63/index.html
Cannot resolve hostname (tmp)

I beleive it is browser dependent problem.
It should always work with path file:///tmp/RtmpcvwPCH/viewhtml4a5376c24e63/index.html

Session

> sessionInfo()
R version 3.1.1 (2014-07-10)
Platform: x86_64-pc-linux-gnu (64-bit)

locale:
 [1] LC_CTYPE=en_IE.UTF-8          LC_NUMERIC=C                  LC_TIME=en_IE.UTF-8           LC_COLLATE=en_IE.UTF-8        LC_MONETARY=en_IE.UTF-8       LC_MESSAGES=en_IE.UTF-8       LC_PAPER=en_IE.UTF-8          LC_NAME=en_IE.UTF-8          
 [9] LC_ADDRESS=en_IE.UTF-8        LC_TELEPHONE=en_IE.UTF-8      LC_MEASUREMENT=en_IE.UTF-8    LC_IDENTIFICATION=en_IE.UTF-8

Installation details

> devtools::install_github(c("ramnathv/htmlwidgets", "smartinsightsfromdata/rpivotTable"))
Downloading github repo ramnathv/htmlwidgets@master
Installing htmlwidgets
'/usr/lib/R/bin/R' --vanilla CMD INSTALL '/tmp/RtmpcvwPCH/devtools4a536b6c70b1/ramnathv-htmlwidgets-083f018' --library='/home/cracs/R/x86_64-pc-linux-gnu-library/3.1' --with-keep.source --install-tests 

* installing *source* package ‘htmlwidgets’ ...
** R
** inst
** preparing package for lazy loading
** help
*** installing help indices
** building package indices
** installing vignettes
** testing if installed package can be loaded
* DONE (htmlwidgets)
Downloading github repo smartinsightsfromdata/rpivotTable@master
Installing rpivotTable
'/usr/lib/R/bin/R' --vanilla CMD INSTALL '/tmp/RtmpcvwPCH/devtools4a53783a6b90/smartinsightsfromdata-rpivotTable-fcc20de' --library='/home/cracs/R/x86_64-pc-linux-gnu-library/3.1' --with-keep.source --install-tests 

* installing *source* package ‘rpivotTable’ ...
** R
** inst
** tests
** preparing package for lazy loading
** help
*** installing help indices
** building package indices
** installing vignettes
** testing if installed package can be loaded
* DONE (rpivotTable)

[INFO] Updating the R environment index started...

[INFO] The R environment index was updated successfully.

Using `derivedAttributes` parameter

Hi,

I am trying to use derivedAttributes parameter but haven't been successful. Is it supported in the current version? Could you share an example if it is?

Here's the example I tried -

library(htmlwidgets)
library(rpivotTable)

df = data.frame(a = 1:10, b = 11:20)

my_func = JS("var c = function(record) {
    return record.a / record.b;
   }")

rpivotTable(df, derivedAttributes = my_func)

In the browser console I see this error -

SyntaxError: expected expression, got keyword 'var'
window.HTMLWidgets.evaluateStringMember() htmlwidgets.js:638
window.HTMLWidgets.staticRender/</<() htmlwidgets.js:532
forEach() self-hosted:216
forEach() htmlwidgets.js:55
window.HTMLWidgets.staticRender/<() htmlwidgets.js:466
forEach() self-hosted:216
forEach() htmlwidgets.js:55
window.HTMLWidgets.staticRender() htmlwidgets.js:464
htmlwidgets.js:544

Make use of `overwrite` explicit?

@steadyfish @King23 I would appreciate your input (as well as the input of anybody else of course) as users of this package and especially of this functionality.

The way that pivottable makes the continuos programming of the pivot table possible is through a parameter called overwrite. In Nicolas words:

overwrite is a boolean defaulting to false which controls what happens if this function is called repeatedly on the same element. If set to true, the options object overwrites the current state of the UI. If set to false, only the input data set changes, and the state of the UI remains the same, unless this is the first call, at which point the UI will be set to the options

In fact, to make rpivotTable programmable I simply "forced" a value of true for overwrite in the parameters list in the JS code.
In hindsight I sort of regret this approach, as prevents to do the opposite, sending different datasets keeping the metadata set constant.

Do you (or anybody else) see a problem if I bring this parameter into the rpivotTable calling parameter set, possibly as:

rpivotTable(
  Titanic,
  rows = "Survived",
  cols = c("Class","Sex"),
  aggregatorName = "Sum as Fraction of Columns",
  inclusions = list( Survived = list("Yes")),
  exclusions= list( Class = list( "Crew")),
  vals = "Freq",
  rendererName = "Table Barnhart",
 overwrite = TRUE
)

Probably to avoid to break existing working code the parameter default could be set to TRUE in any case.

Any comment is appreciate.

CRAN?

Are you planning to push rpivotTable to CRAN? I think everything works with the version of htmlwidgets on CRAN

An error occurred rendering the PivotTable results.

Hi,

Thanks for providing this great package. It works very well in Rstudio, however, when I want to use it in shiny, it gave me this error for chart:
An error occurred rendering the PivotTable results.

Pivot table was working but all the charts gave me the error. How can I fix it?

My code:
ui:
tabPanel("Daily Result",rpivotTableOutput("test"))

server:
output$test <- renderRpivotTable({
tt<-data.frame(c(1,2,3,4,1,2,3,4),c('a','b','c','d','c','d','a','b'))
colnames(tt)<-c('x','y')
re=rpivotTable(data=tt)
re
})

exclusions don't work with one column

Hi,
First of all, thank you for this wonderful package! I have a quite peculiar problem.
I'm trying to use exclusions parameter. When I add two columns from which I exclude certain values then everything works (you can see that names of columns are tilted):
exclusions_two_cols
If I use only one column then it doesn't:
exclusions_one_col

Code:

rpivotTable(
   Titanic,
   rows = "Survived",
   cols = c("Class","Sex"),
   aggregatorName = "Sum as Fraction of Columns",
   exclusions = list(
                    Survived = as.list("No")
                    , 
                    Class = as.list("1st")
                     ),
   vals = "Freq",
   rendererName = "Table Barchart"
)

My session info:

> sessionInfo()
R version 3.2.2 (2015-08-14)
Platform: x86_64-pc-linux-gnu (64-bit)
Running under: Ubuntu 14.04.3 LTS

locale:
 [1] LC_CTYPE=pl_PL.UTF-8       LC_NUMERIC=C               LC_TIME=pl_PL.UTF-8       
 [4] LC_COLLATE=pl_PL.UTF-8     LC_MONETARY=pl_PL.UTF-8    LC_MESSAGES=pl_PL.UTF-8   
 [7] LC_PAPER=pl_PL.UTF-8       LC_NAME=C                  LC_ADDRESS=C              
[10] LC_TELEPHONE=C             LC_MEASUREMENT=pl_PL.UTF-8 LC_IDENTIFICATION=C       

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base     

other attached packages:
[1] rpivotTable_0.1.5.8

loaded via a namespace (and not attached):
[1] htmlwidgets_0.5.1 htmltools_0.2.6   tools_3.2.2       rstudioapi_0.3.1 
[5] yaml_2.1.13       rstudio_0.98.1103 jsonlite_0.9.17   digest_0.6.8    

js errors in console

rpivotTable seems to work fine. However, any idea how I might get rid of the errors in the js console (chrome) with rpivotTable in Shiny? Does an addresourceadd need to be added perhaps? This is using Shiny 0.11.1

screen shot 2015-02-11 at 10 48 44 am

Interavtivity with shinyFiles

Hi, great package, I have used it to great effect in a data explorer in our company. So good it was that I have started using it in a second project. Alongside the (multiple) file uploader package shinyFiles (find it on CRAN).

ShinyFiles uses htmlWidgets to pass information between the server and ui. Where one of the htmlWidgets javascript files calls the renderValue js function. Unfortunatly rpivotTable.js also has a function called renderValue() and this is where things go wrong. There appears to be cross talk which means that I can't upload multiple files and use rpivotTable in the same shiny app.

Given the number of dependencies, it might be easier to change rpivotTable than htmlWidgets, is this change possible?

Thanks again

(PS I have removed a coluple of company-speciic packages from the sessionInfo())

Example Script

library(shiny)
library(rpivotTable)
library(shinyFiles)

# Define server logic required to draw a histogram
server <- function(input, output, session){
  #volumes <- getVolumes()
  volumes <- c(`Local (C)`="C:", 
               `Data (M)`="M:")
  shinyFileChoose(input = input, 
                  id = 'file', 
                  roots = volumes, 
                  session = session)
  output$filepaths <- renderPrint({parseFilePaths(volumes, input$file)})
  output$bPivotTable <- renderRpivotTable({
    rpivotTable(data = iris)
  })
}

ui <- fluidPage(
  sidebarLayout(
    sidebarPanel(
        fluidRow(strong("Choose files to upload:")),
        fluidRow(
          shinyFilesButton(id = "file", 
                           label = "Files", 
                           title = "Upload Files",
                           multiple = TRUE)
        )
    ),
    mainPanel(
      verbatimTextOutput('filepaths'), 
      rpivotTableOutput("bPivotTable")  
    )
  )
)

print(shinyApp(ui = ui, server = server))

Session Info

R version 3.3.0 (2016-05-03)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows 7 x64 (build 7601) Service Pack 1

locale:
[1] LC_COLLATE=English_United Kingdom.1252 LC_CTYPE=English_United Kingdom.1252 LC_MONETARY=English_United Kingdom.1252
[4] LC_NUMERIC=C LC_TIME=English_United Kingdom.1252

attached base packages:
[1] splines stats graphics grDevices utils datasets methods base

other attached packages:
[1] stringr_1.0.0 lme4_1.1-12 Matrix_1.2-6 ggplot2_2.1.0 reshape2_1.4.1
[8] readxl_0.1.1 RODBC_1.3-13 leaflet_1.0.1 lubridate_1.5.6 rpivotTable_0.1.5.20 shiny_0.13.2 shinyFiles_0.6.0

loaded via a namespace (and not attached):
[1] Rcpp_0.12.5 magrittr_1.5 MASS_7.3-45 munsell_0.4.3 lattice_0.20-33 colorspace_1.2-6 xtable_1.8-2 R6_2.1.2
[9] minqa_1.2.4 plyr_1.8.4 tools_3.3.0 grid_3.3.0 nlme_3.1-127 gtable_0.2.0 htmltools_0.3.5 yaml_2.1.13
[17] digest_0.6.9 RJSONIO_1.3-0 nloptr_1.0.4 htmlwidgets_0.6 mime_0.4 stringi_1.1.1 scales_0.4.0 jsonlite_0.9.21
[25] httpuv_1.3.3

How I set the number of decimal

I notice that currently 2-digit decimal is set as default.
Is it possible that I could change this value?

Thank you in advance.

Using rpivotTables in flexdashboard.

When using rpivotTable inside a flexdashboard with a long table, the dashboard could not display correctly. Only fixed viewpoint could be displayed. It would be nice if something like scrollbars appear.

In shiny application, rpivotTable works fine

My declaration for flexdashboard


---
title: "Test rpivotTable"
output: 
  flexdashboard::flex_dashboard:
    orientation: columns
    vertical_layout: scroll
    horizontal_layout: scroll

---

Hide Column and Row Totals in Shiny

Hi! Is there a way to remove the row and totals from the rpivotTableOutput()? My output has 3x8 categories, so the total cells show totals for each category, which I don't want.

Cumulative sum?

Hi, I am not very good with JavaScript. Could you please help me create CumSum functionality? Thank you!

rendererName parameter is not working

Hi,
It turns out that the rendererName argument of rpivotTable functions doesn't work :(
Here is a screen with example from documentation:
rpivottable_renderer_notworking

My session info:

> sessionInfo()
R version 3.2.1 (2015-06-18)
Platform: x86_64-pc-linux-gnu (64-bit)
Running under: Ubuntu 14.04.2 LTS

locale:
 [1] LC_CTYPE=pl_PL.UTF-8       LC_NUMERIC=C               LC_TIME=pl_PL.UTF-8       
 [4] LC_COLLATE=pl_PL.UTF-8     LC_MONETARY=pl_PL.UTF-8    LC_MESSAGES=pl_PL.UTF-8   
 [7] LC_PAPER=pl_PL.UTF-8       LC_NAME=C                  LC_ADDRESS=C              
[10] LC_TELEPHONE=C             LC_MEASUREMENT=pl_PL.UTF-8 LC_IDENTIFICATION=C       

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base     

other attached packages:
[1] rpivotTable_0.1.5.7

loaded via a namespace (and not attached):
[1] htmlwidgets_0.5.1 htmltools_0.2.6   tools_3.2.1       rstudioapi_0.3.1  yaml_2.1.13      
[6] rstudio_0.98.1103 jsonlite_0.9.17   digest_0.6.8

cannot coerce type 'closure' to vector of type 'character'

Good morning,

I've tried following the rpivotTable example from an article I read on LinkedIn, but I'm getting this error when I call the rpivotTable function.

The code (as on LinkedIn) is:

Install packages

library(devtools)
install_github("ramnathv/htmlwidgets")
install_github("smartinsightsfromdata/rpivotTable")

Load rpivotTable

library(rpivotTable)
data(mtcars)

One line to create pivot table

rpivotTable(mtcars, rows="gear", col="cyl", aggregatorName="Average",
vals="mpg", rendererName="Treemap")

Any suggestions on how to fix it as I'd like to see if this can help my team out with any of our current or upcoming client projects?

No scrolling in large pivottable

When I create a pivottable with a lot of rows / columns, It is not possible to scroll. I tested this in rstudio and in shiny. Result is the same;

Gathering the results from analysis

Is there a way to save the results from analysis over the pivot table to a Data Frame? It would be very useful. Today the analysts create a lot of SQL queries or use Excel, with your Pivot Table they can use it and write it on a SQL Table or export to an Excel spreadsheet.

Remove limit of list Category

I have created an rpivottable and for some of the factors that I want to drag and drop to create tables and graphs, they contain more than 500 factors. Is there a way to eliminate the limit of each factor so that when I click on any option in the pivottable, it will show me a list of the options and from there I can filter out what I want? Currently, when I click on the factors that have too large of a list, it states, "too large to list". And when I try and create the graphs, it doesn't work because there are too many factors.

How to define derived attributes

I need a derived attribute, which is the ratio of the other two variables. I know PivotTable.js supports the derived attributers. How I can do this in the R package? Thank you very much!

Y-axis for the charts are not displaying properly in iframe

Hi @smartinsightsfromdata,

This package is really awesome, like it very much! Recently i am using this package to display the data by using line chart and it is working fine in Shiny. But when i link this shiny page to another website (using php) and display in that website's iframe, the Y-axis getting crazy and the interval between the Y-axis value label is very huge causing the Y-axis very long compare to the plot in Shiny. It might not be the rpivotTable package problem, but i just want to see if you have any idea anything i can configure for the rpivotTable so it can display properly in iframe of another webpage.

This is my R code, as you can see i have setup the height and it can display properly in Shiny.
rpivotTableOutput("pivot", width="100%", height="900px")

Below is the code for the iframe, even i configured the iframe height to smaller size but it will not resize the pivot table. The Y-axis for the line charts grow very long compare to how it looks like in Shiny.

image

Appreciate if you can advise. Thanks and have a nice day!

isolate the variable drag-and-drop

Nice binding!

Question: Is it possible to use the variable drag-and-drop functionality without the tables/graphs etc.? R could then handle the plotting, summarizing, etc.

Version 0.1.5.20 description?

The index.html page on cran.r-project.org references version 0.1.5.20; however, the NEWS.pdf document (here and on cran) includes references to only Version 0.1.5.9. Where can we go to see a description of the latest changes in version 0.1.5.20?

The 'rendererName' argument not working

Hi there,

I've noticed that the 'rendererName' doesn't work. There is no error thrown, it just always defaults to table no matter what renderer you select.

rpivotTable not rendering in Shiny

Just wanted to start by saying that this package is great! rpivotTable works so well within Rstudio - I'm just having some problems getting it to work with Shiny.

I'm using some of your code as a test (see below). The issue is that when I run the code a webpage appears but without the pivot table. I'm using R 3.2.0, shiny 0.11.1 and rpivotTable 0.1.3.5. I've tried uninstalling and then reinstalling everything but a pivot table still won't appear.

Has anyone else had shiny issues with rpivotTable 0.1.3.5? I think the issue could either be due to a problem in CSS (maybe it is creating a background in front of the table) or a version issue.

Any help would be amazing! Thanks.

library(shiny)
library(shinydashboard)
library(rpivotTable)
library(ggplot2)

data(diamonds)

header <- dashboardHeader(title = "Data Profiler")

sidebar <- dashboardSidebar()

body <- dashboardBody(
tags$head(tags$style(
type = 'text/css',
'#test{ overflow-x: scroll; }'
)),
rpivotTableOutput("test")
)

shinyApp(
ui = dashboardPage(
header, sidebar, body),
server = function(input, output) {

output$test <- rpivotTable::renderRpivotTable({
  rpivotTable(data = diamonds)
})

}
)

rpivotTable(data = diamonds)

Export rpivottable output as image

I recently started using rPivotTable to produce some impressive charts and tables. I am using rPivotTable in a Shiny application. I was wondering if it is possible to export the output of the rPivotTable(Table, Bar chart, line chart etc) as image from the web browser. In RStudio(without Shiny), it can be done as the viewer has an option for Export->Save as Image. Is there any way to save the charts and tables.
I have also added this question in Stackoverflow.
http://stackoverflow.com/questions/37950488/export-rpivottable-output-as-image-in-shiny

Thanks.

Issue displaying rpivott

Hi @smartinsightsfromdata I have this result when I use
rpivotTable(data = dt, rows = "Party", cols = "Province", vals = "votes", aggregatorName = "Sum")

image

I don't know if it's a new issue (this package is relatively new).

pandoc error 67 when using rmarkdown with rpivottable

Got this error:

/home/expat/R/x86_64-pc-linux-gnu-library/3.2/rpivotTable/htmlwidgets/lib/jqueryui/images/animated-overlay.gif: openBinaryFile: does not exist (No such file or directory)
Error: pandoc document conversion failed with error 67

it looks like the whole image folder is not there and pandoc somehow needs it

pandoc commandline (used knit HTML from rstudio)
/usr/bin/pandoc +RTS -K512m -RTS pivottable.utf8.md --to html --from markdown+autolink_bare_uris+ascii_identifiers+tex_math_single_backslash-implicit_figures --output pivottable.html --smart --email-obfuscation none --self-contained --standalone --section-divs --template /usr/local/lib/R/site-library/rmarkdown/rmd/h/default.html --variable 'theme:bootstrap' --include-in-header /tmp/RtmpNYrrbC/rmarkdown-strb2e44afa1939.html --mathjax --variable 'mathjax-url:https://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML' --no-highlight --variable highlightjs=/usr/local/lib/R/site-library/rmarkdown/rmd/h/highlight

Interface styling options

Hello, gents,

Excellent work here. I'm working with Shiny. This package has been a godsend, literally. Thank you.

One rough are, however, is related to aesthetics. Any chance for better control over table aesthetics, directly from within R? For example, maximum column sizes or a separable, absolute table for the filters? Also, options to move the legends around would be nice.

I am happy to work on this myself, but have only rudimentary java and css skills. I am, however, willing to put in the effort to learn. Ideally, this could rival--say--Tableau in terms of overall UX.

Anyone willing to help me get started int his direction?

issue with htmlwidgets & shiny server

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 on the server it crash and 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,

Confict with dateRangeInput

Hi,
I have upgraded the package and I have found conflicts with shiny's dateRangeInput (dateInput has the same problem). It seems to be some javascript confilct.

library(shiny)
library(rpivotTable)

ui = shinyUI(fluidPage(
  dateRangeInput('dateRange',
                 label = 'Rango de Fechas: yyyy-mm-dd',
                 start = as.Date("2015-01-01"), end = Sys.Date() -1
  ),
  rpivotTableOutput('table' )

))

server = function(input, output){
  output$table <- renderRpivotTable({
    iris %>%
      tbl_df %>%
      filter( Sepal.Width > 3 ) %>%
      rpivotTable
  })
}

shinyApp(ui = ui, server = server)

Thanks for your help!

sorting value labels for factors in Tables

Hi I'm really impressed with your implementation of pivot tables. I just have a bit of cosmetic issue: I'm trying to get output for a low/medium/high factor variable to have tabular out put that prints in the right order instead of alphabetical: high/ low/ medium

I saw in nicolas.kruchten's example where he tries to sort the labels in the javascript he does some special sortAs variable and then specificies the attributes for the day and month ordering in an if statements. How might I do this in your R package?

I'm not that up on javascript, so I don't know how I might embed this technique in my markdown file. Any advice would be much appreciated.

<script type="text/javascript">
        google.load("visualization", "1", {packages:["corechart", "charteditor"]});
        $(function () {

            var dateFormat =       $.pivotUtilities.derivers.dateFormat;
            var sortAs =           $.pivotUtilities.sortAs;
            var tpl =              $.pivotUtilities.aggregatorTemplates;
            var renderers =        $.pivotUtilities.renderers;
            var gchart_renderers = $.pivotUtilities.gchart_renderers

            $.get("montreal_2014.csv", function(montreal_2014) {
                $("#output").pivotUI($.csv.toArrays(montreal_2014), {

                    aggregators: {
                        "Mean Temp (Celcius)":  
                            function() { return tpl.average()(["Mean Temp (C)"])},
                        "Max Temp (Celcius)":   
                            function() { return tpl.max()(["Max Temp (C)"]) },
                        "Min Temp (Celcius)":   
                            function() { return tpl.min()(["Min Temp (C)"]) },
                        "Total Rain (mm)": 
                            function() { return tpl.sum()(["Total Rain (mm)"]) },
                        "Total Snow (cm)": 
                            function() { return tpl.sum()(["Total Snow (cm)"]) }
                    },
                    derivedAttributes: {
                        "year":       dateFormat("Date", "%y", true),
                        "month":      dateFormat("Date", "%m", true),
                        "day":        dateFormat("Date", "%d", true),
                        "month name": dateFormat("Date", "%n", true),
                        "day name":   dateFormat("Date", "%w", true)
                    },

                    sorters: function(attr) {
                        if(attr == "month name") {
                            return sortAs(["Jan","Feb","Mar","Apr", "May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"]);
                        }
                        if(attr == "day name") {
                            return sortAs(["Mon","Tue","Wed", "Thu","Fri","Sat","Sun"]);
                        }
                    },

                    hiddenAttributes: ["Date","Max Temp (C)","Mean Temp (C)","Min Temp (C)" ,"Total Rain (mm)","Total Snow (cm)"],

                    renderers: $.extend(renderers, gchart_renderers),

                    rows: ["year", "month name"],
                    cols: ["day name"]


                });
            });
        });
    </script>

too many to list

Hello,
When the Number of types/values for a variable I get the error "too many to list" when trying to select. Please help on this.

-Mani

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.