I wish to have a shiny app created where I will plot two dataframes in ggplot, then do some simple stats calcs on a variable and plot a summary table underneath it. If I leave the table calculations out then I can plot the line plots just fine and have them change based on the $input function. The problem comes when I try to have the table update based on the $input value from the ui.
yes, you need chains of reactivity so your app runs reactively... thats largely the concept of shiny.
why would copy and pasting be easier, if they have the same content then make a single reactive that is their shared content, and call it twice in the two places its needed.
So my understanding it that if I want both the plot and table to react to the input, all expressions that generate the ggplot line graph and the summary statistics will have to be reactive. In theory this isn't too bad but I have some while loops and some dataframe creations that would have to be reactive, not just simple assignments, which is beyond my knowledge of shiny at the moment.
Complete reactives can return their values immediately; invalidated reactives will kick off their own execution graph.This cycle will repeat until every invalidated output enters the complete (green) state.
While that is the best citation and archival location of the dataset, using Shiny, one can also provide an easy-to-use exploratory web application that you use to make your point that directly loads the data from the archival site. For example, the Board of Fisheries application above lets people who are not inherently familiar with the data to generate graphs showing the relationships between the variables in the dataset.
To extend the layout, we will first nest the existing sidebarLayout in a newverticalLayout, which simply flows components down the page vertically. Thenwe will add a new sidebarLayout to contain the bottom controls and graph.
The easiest path is to create an account on shinyapps.io, and then configure RStudio touse that account for publishing. Instructions for enabling your local RStudio to publishto your account are displayed when you first log into shinyapps.io:
Problem Summary: ggplot2 graphs seem to be of poor quality in shiny, when hosted on shinyapps.io. Graph elements contain visible defects, e.g. dots of geom_point() are not round, some seem like triangles, other like rectangles etc. Legend looks as if it has been blown up from a low-res jpg. My example is here.
Detailed description: Developing a simple Shiny application, I have noticed that ggplot graphs are a bit rough around the edges, and was unable to improve the situation. The example app demonstrates this well enough, notice how the dots seem to be of irregular shape. Their shape improves, approximating circularity, when I increase zoom (in Chrome) to 200% or more. On 100% zoom the whole graph looks weird and not smooth. As if when an image resolution is decreased by the factor of 0.77 or something like that, you get minor distortion artefacts; the similar effect is here. The easiest way to see it, is to download the image at 100% zoom (right click, save as), and then increase zoom on the local copy. You will see how dots are far from being round. The code for server.R and ui.R is very simple:
EDIT 2: for this question to be of more value to other SO users, here are the screenshots of the graph before and after using the Cairo device (use zoom in your browser to get a better look at the difference):
Cairo is a 2D graphics library with support for multiple output devices. Currently supported output targets include the X Window System (via both Xlib and XCB), Quartz, Win32, image buffers, PostScript, PDF, and SVG file output. Experimental backends include OpenGL, BeOS, OS/2, and DirectFB. Cairo is designed to produce consistent output on all output media while taking advantage of display hardware acceleration when available (eg. through the X Render Extension). Personally, I use it for the alpha channel (transparency options).
I have a input where the user can select which type of graph they want to see. But my problem is I can't figure out to get the graph to change to based off the input. Here a screenshot of what I am working with.
Hello everyone , i would like to have a Shiny application which could print an interactive graph (thanks to the package plotly on Rstudio) with the selection of the x and y parameters with this function : selectInput()
The data come from a database already import in Rstudio named table31.
Here is my code :
forum2.PNG782488 9.54 KB
I would like to adjust my generated graph. Looking at it, it looks like a stretched graphic (I've inserted an image for you to see). I could centralize it more, make it more "beautiful", let's put it that way.
I am not sure if Im doing this the right way (I am open for suggestions!). However what I try to do if to create a Shiny app where i can pick a bar and then the bar should be highlighted in the graph.
In this article we walk you through the steps of building a shiny app for visualizing disease occurrence in the United States from 1928-2011. The finished app is available at the following link. Take a look at the app, play with it, and then come back and build it yourself!
Inputs and outputs are the key components of the ui. Inputs are the features of the app that users interact with, such as a numeric slider bar, date range, check boxes, text input, or a drop down menu. You can see all the options included in the standard shiny package at -gallery/.
Often when building a shiny app, you will be working with a dataset that you will want to change in some way to reflect user inputs. To do this, you can create a reactive expression in the server object that will make those changes to the data while the app is running.
Before we add the interactive customizations to the app, we will add a line graph plotting disease frequencies over time in the main panel. As we add our customizations, the user will be able to manipulate the data displayed in this graph.
At this point your app.R file should match the code below. If you run the app as is, you get a very busy graph, with the aggregated frequencies across all states displayed for every disease. (Try it!) Allowing the user to select the data they are most interested in will result in a much more visually appealing and readable graph.
Finally, our last output will be a second graph, a box plot, this time using plotly instead of ggplot. Because plotly graphs are interactive, we need to use different output and render functions. Instead of the plotOutput() and renderPlot() functions we used to create the line graph, we will use plotlyOutput() and renderPlotly().
I'm creating a shiny web app and would like to set the size of the plot and scale. What I mean by that is I'm looking for a way to set a finite height/width for my plot, and then scale that set sized image to the mainPanel( plotOutput ()) area.
The options specified in Server.R did take effect. (I just plotted two graphs of different sizes each.) I also took @Manetheran's suggestion and made cex and cex.axis into parameters. They seem to be working.
So... I cannot create a smaller image in pixels (which creates larger text size relative to the overall plot) and then make it bigger to have bigger text. One does, indeed, need to create a graph the size of the plot area (or larger) and scale the text to satisfaction via the plot (or ggplot) command itself.
im trying to create a popup window depending on a click event in Shiny.The window should open up when the user clicks on a row in a DT table. It should contain a plotly graph, that is filtered by the row element in column v1 in df (when a row with v1 == "B" was clicked, all rows with v1 == "B" go in the graph). I can create all objects (see code), but struggle with dependent filtering and opening the popup window based on row click event.
As soon as the graph is redrawn, the click event becomes invalidated. Because of the reactive programming approach this means that Shiny recalulates all the clicks dependencies (such as the output), and returns no country information. We need to store the country information, and only update this when a new click event is detected. We need to do two things:
The final thing to do is to add the historic data to the plot, if a country is selected. Modify the renderPlot() to produce the regular graph if the length of activeCountry() is 0 (i.e. no country is selected), and to produce the plot including the historic data otherwise (the code example at the start of the episode shows how to add historic data to a plot).
I try to refresh a plot in R shiny that should be refreshed if either a new input argument is entered OR an action button is pressed. This should be straightforward, but unfortunately I can't solve it, despite googling/reading instructions for some time. Any advice would be recommended. Any solutions on the web seem to put the whole renderplot function inside the observeEvent function, but I also need the renderplot in addition outside of it to account for the possibility of just entering inputs without pressing the action button.
However when doing both at the same I fail: I first tried to copy the renderplot function including the resulting output twice one time within an observeEvent function (to account for clicking the action button) and one time outside of an observeEvent (to account for only refreshing the inputs to the plot) but this leads only to a greyed out graph that refreshes after 10 seconds delay when pressing the action button. I imagine adding the reactive click input generated from clicking the action button directly to the renderplot outside of observe event , but so far I couldn't get it to run. Any recommendations would be much appreciated.
I am using shiny package in R to take input from user and plot the X and Y variable against each other as line plot.There is no error displayed.Everything is displayed except for the graph.Please can someone help why the graph is not displayed .Here is the ui.r file
df19127ead