logo
down
shadow

How to enable user to switch between ggplot2 and gVis graphs in R Shiny?


How to enable user to switch between ggplot2 and gVis graphs in R Shiny?

Content Index :

How to enable user to switch between ggplot2 and gVis graphs in R Shiny?
Tag : r , By : Jason Haar
Date : November 24 2020, 05:44 AM


Comments
No Comments Right Now !

Boards Message :
You Must Login Or Sign Up to Add Your Comments .

Share : facebook icon twitter icon

How can I increase the absolute size of my ggplot2 graphs in R Shiny?


Tag : r , By : Stone
Date : March 29 2020, 07:55 AM
around this issue In renderPlot, you can add parameters height and width in pixels.
(Added, and addition corrected in April 2017)

How to display two gvis gauge meters side by side using Shiny R


Tag : r , By : Dasharath Yadav
Date : March 29 2020, 07:55 AM
it helps some times You can use column to specify the layout or you can use div and go with tags$style and use display:inline-block
rm(list = ls())
library(shiny)
library(googleVis)

ui =(fluidPage(
  titlePanel('Guage'),
  sidebarLayout(
    sidebarPanel(
      numericInput('n1', 'Enter your Base Accuracy', 40, 0.5, 100),


      numericInput('n2', 'Enter your Model Accuracy', 40, 0.5, 100)
    ),
    mainPanel(
      tabsetPanel(
        tabPanel("Accuracy Guage",
                 column(4,htmlOutput("view1")),
                 column(4,htmlOutput("view2"))
      )
    )
  ))))
server = function(input, output) {

  output$view1 <- renderGvis({
    df1 <- data.frame(Label = "Base Accuracy", Value = input$n1)
    gvisGauge(df1,
              options=list(min=0, max=100, greenFrom=90,
                           greenTo=100, yellowFrom=75, yellowTo=89.99,
                           redFrom=0, redTo=74.99, width=300, height=300));  

  })

  output$view2 <- renderGvis({
    df2 <- data.frame(Label = "Model Accuracy", Value = input$n2)
    gvisGauge(df2,
              options=list(min=0, max=100, greenFrom=90,
                           greenTo=100, yellowFrom=75, yellowTo=89.99,
                           redFrom=0, redTo=74.99, width=300, height=300));  

  })
}
runApp(list(ui = ui, server = server))

Uncompleted code Shiny App, mtcars dataset, how to make four user inputs to four different graphs


Tag : r , By : Praetoriansentry
Date : March 29 2020, 07:55 AM
I hope this helps . I think you need to use renderPlot if you want to see plots in UI like this
 library(shiny)
    library(ggplot2)



    myData <- mtcars

    ui <- fluidPage(
        titlePanel("cars graphs"),
        sidebarLayout(
            sidebarPanel(selectInput("carsInput", " car graph Choice",
                                     choices = c("counts", "Horizontal counts", "stacked bar chart", "grouped bar chart"), 
                                     selected = "counts" )),
            mainPanel( plotOutput("plotOutput"),
                       br(), br(),
                       tableOutput("results")
            )
        )
    )

    server <- function(input, output) {

        output$plotOutput <- renderPlot({
            if (input$carsInput == "counts")
            {


                counts <- table(mtcars$gear)
                barplot(counts, main="Car Distribution", 
                        xlab="Number of Gears")

            }
            if (input$carsInput == "Horizontal counts")
            {

                counts <- table(mtcars$gear)
                barplot(counts, main="Car Distribution", horiz=TRUE,
                        names.arg=c("3 Gears", "4 Gears", "5 Gears"))

            }

            if (input$carsInput == "stacked bar chart")
            {


                counts <- table(mtcars$vs, mtcars$gear)
                barplot(counts, main="Car Distribution by Gears and VS",
                        xlab="Number of Gears", col=c("darkblue","red"),
                        legend = rownames(counts))

            }
            if (input$carsInput == "grouped bar chart")
            {


                counts <- table(mtcars$vs, mtcars$gear)
                barplot(counts, main="Car Distribution by Gears and VS",
                        xlab="Number of Gears", col=c("darkblue","red"),
                        legend = rownames(counts), beside=TRUE)

            }
        })

    } 



    shinyApp(ui = ui, server = server)

Suppressing non-integer axis breaks in ggplot2 graphs (in Shiny app)


Tag : r , By : Kyle
Date : March 29 2020, 07:55 AM
like below fixes the issue for your help! It seems that the answer was much simpler as I thought. Putting breaks = function(x) unique(floor(pretty(x))) in my scale_x_continuous() function produced integer-only breaks, even without transforming the data into Date format. Removing the unique() does not change the behavior in my case, but it might do in other cases.

How switch between geom_line and geom_bar visualization in ggplot2 in Shiny - R


Tag : r , By : Ian Badcoe
Date : March 29 2020, 07:55 AM
I wish this helpful for you You can save ggplot objects to a variable and build onto it however you need. Outside of a Shiny context, you could do this by referring to a variable, or encapsulating the task of adding onto a ggplot in a function. Inside a Shiny context, you can decide what to add to the object based on a user input.
For example, in a plain R context:
library(ggplot2)

set.seed(123)
df <- data.frame(
  month = 1:10,
  value = runif(10)
)
plot_base <- ggplot(df, aes(x = month, y = value)) +
  scale_y_continuous(labels = scales::percent)
plot_type <- "Line"

if(plot_type == "Line") {
  p <- plot_base +
    geom_line()
} else {
  p <- plot_base +
    geom_col()
}
p
plot_type <- "Bar"

if(plot_type == "Line") {
  p <- plot_base +
    geom_line()
} else {
  p <- plot_base +
    geom_col()
}
p
Related Posts Related QUESTIONS :
  • add row based on variable condition in R
  • Generating the sequence 111122222333334
  • Unable to use has_goog_key() in R
  • how to multiply each row with a scaler in corresponding column?
  • R is not recognizing levels of a factor as the same. Is there a way to do this?
  • Calculating mean of replicate experiment result values in a column based on multiple columns using R
  • Best method to extract the first instance of a string between specified keywords using data.table
  • ignore optional combination of alphanumeric characters in str_extract
  • Why tracemem shows two copies when modification occurs inside function body?
  • Can't use mppm on multitype point patterns
  • How to move selected matrix rows to top of matrix based on a selection vector of row names
  • Combining expressions with a common operator
  • Passing string through multiple filters for matching
  • Convert two columns in R to rows of unique occurrence
  • How to create a dataframe using a function based on user-input?
  • How to access the visited vertices in a given shortest path using R igraph
  • Differences in Unicode character output with print()
  • Extracting Function or Objects from a String and then Piping Them with Magrittr/Dplyr
  • renderUI not evaluated until it is rendered
  • Find the maximum absolute value by row in an R data frame
  • Extracting data from irregular lists using purrr:map()
  • transforming data based on range of column in r
  • Identify and subset rows with some similar information
  • converting character from mongolite to timestamp in R
  • Create list from two vectors with every combo of each
  • Error in running a spread because of unique 'key combinations'; combining rows of data
  • visualize numerical strings as a matrixed heatmap
  • how to make a blocked matrix?
  • How to summarize with two functions using with dplyr
  • Dataframe is no longer the same after being saved to Excel and read back in
  • Create duplicate rows using based on availability of data
  • Keep empty groups when grouping with data.table in R
  • Grouping of Event Time Data based on multiple, iterative conditions
  • Formatting Numbers in Flextable for Specific Columns
  • How to store results from for-loop into a dataframe
  • How to select the values in my dataframe which has logical operator "<" (less than), divide them by two, an
  • Rowwise extract data between two strings
  • Convert a string separate by . and +
  • stacking function for values in R
  • dplyr coerces characters to factors
  • How do I use spread and group_by on a single row dataset
  • Replacing values in one matrix with values from another
  • Aggregate data and exclude duplicates in one column
  • Perform an R data.table binary search with OR select
  • How can I include a function in the Standard Deviation parameter of pnorm
  • How to get a tidy excel output of P values from R
  • Rotate boxplot legend (R, ggplot2)
  • dplyr::n() returns “Error: Error: n() should only be called in a data context ”
  • Extract fix columns and one variable column from a list of df´s in R
  • A function that can translate DNA sequence to binary code
  • I want to extract 365 netcdf files using loop
  • rvest vs RSelenium results for text extracting
  • Converting wide data to tall data
  • How to remove vertical white lines when using ggsave in R?
  • R-Shiny error: "renderDataTable" and "server=FALSE"
  • Read csv file with selected rows using data.table's fread
  • how to resolve an error like non numeric argument to binary argument?
  • If value exists in environment
  • R get one value according to some rules in each group
  • Use any apply method to find difference between max and min score for each students
  • shadow
    Privacy Policy - Terms - Contact Us © scrbit.com