I'm developing a Shiny application that provides interaction between a table with selection and a plot also with selection. When the plot is clicked to select a point, I would like to cascade that selection to the table. I've found this page (https://yihui.shinyapps.io/DT-proxy/) which describes exactly the process I'm trying to accomplish using dataTableProxy and selectRows functions. But even their example code does not work on my machine. I get an error saying "could not find function dataTableProxy"
I have version 0.1 of DT, shiny 0.12.2, shinydashboard 0.5.1, and R 3.1.2. Even looking at the DT documentation I see no mention of a dataTableProxy function.
Related
I would like to know if a DT::datatable output object's columns can be automatically adjusted inside a Shiny App? This seems like a very popular interface but I can't seem to do a simple manual column size adjustment, like the Rhandsontable, with the following call
hot_cols(manualColumnResize = TRUE)
If there is an option to do this via JavaScript I'll take that as well, as I've already search for how to do this with pure R syntax to no avail. Thanks.
Ok, I understand now, not from DT, but you could use {DataEditR} package instead.
I am trying to make some GUI for my CRAN package
some f function that locally launches a popup with a few params rendering a few outputs, like launching locally a simple shiny app.
the popup permits to select the parameters easily and then a "validate" button triggers the return of fwith the selected parameters, like shiny with stopApp
I have already done that with shiny but i think the result is a bit unsatisfying because shiny apps are slow to launch and stop (if there is an object to serialize i guess).
I have seen that some packages, like vdiffr, seem to answer this problem by making a list of the objects to change, thus they only launch shiny once to change everything with some selecter. If possible I'd like to avoid this solution.
So the question is : is there some kind of GUI framework more convenient than Shiny for this (only local, fast launch and fast return) ? Or some fine way to do that, that is light enough (I don't want to make my package to be extraordinary heavy for a small popup) ?
Here are GUI facilities that come with R (no packages needed):
(1) For sufficiently simple applications select.list, menu, readline, file.choose and choose.dir can be used and will present with a text or graphical user interface depending on what environment the user has. These all come with R and launch very quickly and are easy to program. See the help pages of those commands and try:
select.list(c("oranges", "apples", "pears"))
menu(c("oranges", "apples", "pears"))
readline("Enter name of fruit: ")
choose.dir()
file.choose()
(2) A possibility which is capable of user interfaces as sophisticated as shiny is the tcltk package. This comes with R so it does not need to be installed. It only needs to be loaded using a library statement. (If a user builds R from source then it is possible to build it without tcltk capability but in 99% of all cases tcltk will be present).
There are a few short examples of R source code employing tcltk here: https://www.stat.berkeley.edu/~s133/Gui-a.html, quite a few more examples at James Wettenhall's site and one can run the Rcmdr R package to see an example of a sophisticated tcltk user interface although running Rcmdr will take longer to load than a simple application due to its large size.
Because tcltk is a part of R itself it does not have a CRAN page but for additional packages that use tcltk look at the reverse dependencies of the tcltk2 package at the bottom of its CRAN page since any package that depends on it must also use tcltk.
That really depends on your coding knowledge. My first approach, however, would be to try to improve your shiny app. For that you can use the profvis package to check why exactly your shiny app is slow. Should you decide to stay with Shiny, there a lot of ways on how to reduce the starting time of Shiny. However, if you should come to the conclusion, that you really want to throw shiny overboard, then you should consider using JavaScript.
Either you write your complete app in pure JavaScript
Or you can use JavaScript within Shiny (e.g. r2d3)
Of course there are other ways as #Pork Chop mentioned of using rmarkdown or normal markdown.
I have gone through this but it does not answer the question.
using Source() in Shiny
I have a land use model in R Script that reads file from one input folder and does a lot of processing and generate outputs. Purpose of shiny is to modify inputs by increasing them by some percentage. My question is, if the model is not packed like a function and as just plain code, would it be able to run and give out required output. Thank you all in advance!
Your R Script needs to:
Be called (with source()) inside the server of your Shiny App.
Use the input$* for the inputs you need to modify.
Having both, there shouldn't be a problem for it to work. But, yes, converting your R Script to a function then sourcing it before the code for the UI would be much better and understandable. Even for you in the future.
I have some tables, e.g. tbl_A, tbl_B & tbl_C that are created in Power BI using R script.
The R script is like this :
df2 <- read.csv("data/customer.csv",quote="")
df2 <- read.csv("data/order.csv",quote="")
#performing various joins / aggregating data
tbl_A <- ...
tbl_B <- ...
tbl_C <- ...
And I choose to load tbl_A, tbl_B & tbl_C when the R script finish executing.
Then those tables are visualized with PowerBI visualization tools such as stacked bar charts.
Everything works fine at this point.
The issue I have is that I would need to update the data (because there is new data everyday) without having each time to recreate the charts.
I tried re-running the R script and loading tbl_A, tbl_B & tbl_C, but this creates new powerBI tables (tbl_A (2), tbl_B (2) ...) and thus is not updating the data that is used in the charts.
Is there any way to update the data generated by R scripts used in PowerBI visualizations ?
Sadly this is not possible as of the current level of R integration in PowerBI.
PowerBI R visualization integration is performed by importing the visual into PowerBI as a static Image. This is explained in the microsoft documentation due to the below limitation:
R visuals are refreshed upon data updates, filtering, and highlighting. However, the image itself is not interactive and cannot be the source of cross-filtering.
R visuals respond to highlighting other visuals, but you cannot click on elements in the R visual in order to cross filter other elements.
Only plots that are plotted to the R default display device are displayed correctly on the canvas. Avoid explicitly using a different R display device.
Basically, PowerBI doesn't incorporate the R graphics device directly into the GUI / visual interface, but rather imports the image. I believe this might be due to how R is integrated. Every R scripts seems to be executed as a self-contained R-session, which closes once the script has finished. Any leftover graphics and data will thus be terminated, and one would have to rerun the script to gain access to the data again.
I would like to build a Wizard for my R package using Shiny Gadgets / RStudio Addins.
Essentially, this should comprise of a series of sequential dialogueViewer() windows.
For this I need:
a way to pass information from one dialogueViewer() to the next.
that only the first dialogueViewer() appears in the Addins menu / dropdown.
EDIT: I started working on something here but I get this error:
Error in handlers$add(handler, key, tail) : Key / already in use`
Any thoughts?
The second problem is relatively easily solved by only registering one function in the inst/rstudio/addins.dcf file.