logo
down
shadow

Dynamic resizing of ggvis plots in shiny apps


Dynamic resizing of ggvis plots in shiny apps

By : Yasir Liaquat
Date : November 17 2020, 01:00 AM
To fix this issue This is now possible in the development version of ggvis. See https://github.com/rstudio/ggvis/pull/381
code :


Share : facebook icon twitter icon
Dynamic ggvis object in Shiny

Dynamic ggvis object in Shiny


By : Santiago Pina
Date : March 29 2020, 07:55 AM
I wish did fix the issue. The error is caused because you have a data.frame with zero rows and have a resulting 1:0. You can change your selected function to:
code :
 selected <- reactive({
    if (is.null(input$items)) {
      return(aalto_all)
    }
    df <- aalto_all[aalto_all[[input$dim]] %in% input$items, ]
    df$keys <-seq_along(df[,1])
    if(nrow(df) == 0){
      return(aalto_all)
    }
    df
  })
Making ggvis plots reactive with shiny

Making ggvis plots reactive with shiny


By : Curtis Jackson
Date : March 29 2020, 07:55 AM
Hope that helps Making the data that you pass to ggvis reactive is the key here, since you want to be able to subset it in response to user input. Also, the maximum_supply is part of input and can be accessed via input$maximum_supply in the supply function and the reactive data.
code :
library(ggvis)
library(shiny)
library(dplyr)

shinyApp(
    shinyUI(fluidPage(
        titlePanel("Example"),
        sidebarLayout(
            sidebarPanel(
                sliderInput("maximum_supply",
                            "Maximum Supply",
                            min = 60,
                            max = 120,
                            value = 90),
                uiOutput("ggvis_ui")
            ),
            mainPanel(
                ggvisOutput("ggvis")
            )
        )
    )),
    shinyServer(function(input, output) {
        supply.function <- function(supply) {
            60 - 60/input$maximum_supply* supply
        }

        dat <- reactive({ data.frame( quantity = 0:input$maximum_supply ) })

        dat %>%
          mutate(price = supply.function(quantity)) %>%
          ggvis(~quantity, ~price) %>%
          layer_lines() %>%
          bind_shiny("ggvis", "ggvis_ui")
    })
)
R/shiny: render elements of plots only when needed in shiny apps

R/shiny: render elements of plots only when needed in shiny apps


By : AbleArcher
Date : March 29 2020, 07:55 AM
should help you out I am currently writing a shiny application. I want to decrease the rendering time of plots (because it takes a long time to initialise a plot). Let's say I want to render a plot dynamically, e.g. , So maybe try grDevices, like here:
server.R:
code :
library("shiny")
library("grDevices")

data(iris)
plot(x=NA, y=NA, xlim=c(0,10), ylim=c(0,10))
p <- recordPlot()

function(input, output, session) {

    output$plotPoints <- renderPlot({
        replayPlot(p)
        points(1:input$ile)
    })
}
library(shiny)

fluidPage(
        sidebarPanel(
            sliderInput("ile", min=1, max=10, label="", value=5)
        ),
        mainPanel(
            plotOutput("plotPoints"))
    )
Delete ggvis plots from shiny

Delete ggvis plots from shiny


By : Chaos
Date : March 29 2020, 07:55 AM
seems to work fine If you tolerate the plots NOT deleted but LOOK LIKE deleted, I think it'll be easy to give bind_shiny() a blank graph.
server.R
code :
  :
  vis2 %>% bind_shiny("plot2")    # the same up to here

  vis3 = mtcars %>%                   # preparation of a blank graph
    ggvis(~mpg, ~wt, opacity := 0) %>%
    layer_points() %>%
    hide_axis("x") %>%
    hide_axis("y")

  observeEvent(input$abutton, {    # When the button is clicked,
    bind_shiny(vis3, "plot")       # bind_shiny() reads and outputs a blank graph, vis3.
    bind_shiny(vis3, "plot2")      # When other Input is done, vis1 and vis2 return.
  }) 

})
How to modularize a dynamic ggvis chart in shiny?

How to modularize a dynamic ggvis chart in shiny?


By : steffyp
Date : March 29 2020, 07:55 AM
I wish did fix the issue. If your problem is that you can't see the plot, that is because in your second recative statement, you need to refer to chart1 as chart1(). In other words, change your charts.R to
Charts.R
code :
chart1 <- reactive({
            cars %>% 
              ggvis(~speed)
 })

chart2 <- reactive({
           chart1() %>% layer_bars()
 })
Related Posts Related Posts :
  • Using German characters (ü, ö, ä, etc.) in text analysis (R)
  • R JAGS: Dimension mismatch
  • R - How to create a function that accepts a code block as parameter?
  • How do I manually set geom_bar fill color in ggplot
  • How can I get my points to connect in a plot and show a trend with NA values in data?
  • Read SPecific lines of a CSV file in R-language
  • ggplot stacked bar plot from 2 separate data frames
  • auto.arima not parallelizing
  • Histogram of binned data frame in R
  • R rewriting stringmanipulations implemented in loop to the R-way
  • get first entries in rows of list?
  • Conditionally removing rows from a matrix in R
  • Using a loop to find P(-1.5<Y<1.5) for a range of sample sizes
  • R-Count and list the maximum count row by row
  • Include Iverson Bracket in R documentation
  • update a data frame and environment in R
  • How to write dynamic cumulative multiple in R
  • format time using as.POSIX in R
  • Change the class of multiple columns
  • Remove period and spaces within column headings nested in a list of data frames
  • R: error message --- package error: "functionName" not resolved from current namespace
  • labels with geom_text ggplot2
  • Passing mongodb ISODate in R
  • Importing "csv" file with multiple-character separator to R?
  • Change row names of a table obtained from a lm regression using xtable function
  • R language iterate over R object
  • How do you delete the header in a dataframe?
  • Re coding in R using complicated statement
  • accumulating functions and closures in R
  • How do you combine two columns into a new column in a dataframe made of two or more different csv files?
  • Twitter authentication fails
  • Summing Values of One Vector Conditional on Values of Another Vector
  • draw cube into 3D scatterplot in RGL
  • lme4 translate formula to code in 3-level model
  • How to draw single axis plot in R
  • Combine geom_tile() and facet_grid/facet_wrap and remove space between tiles (ggplot2)
  • Use snpStats with R version 3.0.1
  • Makefile gives strange error while compiling markdown file into .docx file
  • How to determine whether a points lies in an ellipse
  • Summarize data already grouped in r
  • Is the bigvis package for R not available for R version 3.0.1?
  • Operator overloading in R reference classes
  • How to enable user to switch between ggplot2 and gVis graphs in R Shiny?
  • Is there an easy way to separate categorical vs continuous variables into two dataset in R
  • Correct previous year by id within R
  • Installation of rdyncall package for R
  • ggplot2 plot that evaluates the percentage and mean of a third variable at intersecting points
  • Error Handling with Lapply
  • data.table - split multiple columns
  • How to compute the overall mean for several files in R?
  • R: Graph Plotting: Subscripts in the legend like LaTeX
  • Restructuring data in R
  • Distance of pointsfrom cluster centers after K means clustering
  • R incorrect value of date function
  • Package "Imports" not loading in R development package
  • r - run a user defined function several times by taking column elements as parameters
  • Create input$selection to subset data AND radiobuttons to choose plot type in Shiny
  • Generate crosstabulations from dataframe of categorical variables in survey
  • Restructure output of R summary function
  • New behavior in data.table? .N / something with `by` (calculate proportion)
  • shadow
    Privacy Policy - Terms - Contact Us © ourworld-yourmove.org