Add (multiple) values to a data frame with R shiny -
I am using R glow in combination with ggplot to see a certain dataset. I want the user to be able to add value to this dataset I can do my application to show the original figure + a data point, but as soon as a user enters a new point, the old one goes: User input data is not actually stored in my dataframe. / P>
Some code I am using (name changed for simplicity):
shinyServer (function (input, output) {output $ newPlot <- renderPlot ({ Input $ addButton different ({x & lt;-as.numeric (input $ x) y & lt; - as.numeric (input $ y) if (! Is.na (y)) {data & lt; -rbind ( Data, data .frame (x = x, y = y)) # more code here # and plot here & lt; - myPlot (data) print (plot)}}})}})
Users can pay a value with I especially Can not reproduce you provided by you Code given, but an example might help you. The portion you want is textInput
for x and y, and then deposit those values with a button ( action button ). U The yogi hits the 'add', the recently input values for X and Y are displayed at the top of the original data, but any other value inputted by a user (in the same session) is lost. How can I remember users and plot all my things?
ReactiveValues
, you can store your datasets and update it throughout the session as if you look fit, maybe it helps you to fix your problem. Can do?
is required (bright) data (iris) runApp (list (ui = fluid page (headerpane ('data addition'), sidebarpanel (text input ("species", label = " Numeric input ("sepal.length", label = "add a new seal length", value = ""), numeric input ("sepal.width", labeled "add new species", value = "enter species" = "Add a new spear width", value = ""), numeric input ("petal.length", label = "add a new puntil length", value = ""), numeric in ("Adbooten", "upload!"), Main paneel (table-optup), ("petal.width", label = server = function (input, output) {# just add a new wing width, value = ""), action button ("Table")) Iris [Sample (Nero (Iris), 10),] row.names (iris_sample) & lt; - NULL # Important part of responsive values () Value <- Reactivable valve () value $ $ Df & lt; - Inspecting iris_sample ({# Your action button position if (input $ addButton> gt; 0) {# to renew new line to be connected to your input & Lt; - Separate (c (input $ sepal.length, input $ sepal.width, input $ petal.length, input $ petal.width, input $ species)) # Update your data # List of new lines Note, this prevents a disturbing warning message that will return about rownames due to the different use of Rbiind. Separate (value $ df & lt; - rbind (as.matrix ($ df value), unlist (newLine)}}} output $ table & lt; - renderTable ({$ df}, include.rownames = F)}) )
Comments
Post a Comment