Posts

Showing posts with the label shiny

Is there a way in which we can make the sidebarMenu -> menuItems dynamic?

Is there a way in which we can make the sidebarMenu -> menuItems dynamic? I'm making a ShinyDashboard program and I have some troubles in finding a way to make a loop in the MenuItems. Specifically, I am looking for something that can replace the following lines: menuItem( "Section1", tabName = "Section1", startExpanded = T, menuSubItem("Sub Menu 1", tabName = "tab1"), menuSubItem("Sub Menu 2", tabName = "tab2") ), menuItem( "Section2", tabName = "Section2", startExpanded = T, menuSubItem("Sub Menu 1", tabName = "tab1"), menuSubItem("Sub Menu 2", tabName = "tab2") ) Here is what I tried : lapply(1:2, function(i){ do.call(menuItem, c(text = paste0("Section",i), tabName =paste0("Section",i), startExpanded = T, lapply(1:2, function(j) { menuSubItem(text = paste0("sub menu ", j), tabName...

How to plot a performance/ rate graph ? in r

Image
How to plot a performance/ rate graph ? in r I am trying to plot a graph depicting the performance of the best selling items, moderate selling items and the least selling items and they show which particular brand they belong to and their respective sub_category + category Raw Data : sraw <- structure(list(Date = c("2018-02-28", "2018-02-28", "2018-02-28", "2018-02-28", "2018-02-28", "2018-02-28"), Category = c("Bakery ", "Household ", "Household ", "Personal care", "Personal care", "Breakfast "), Sub_Category = c("Wafers ", "laundry ", "Pet Care", "Womens grooming ", "Womens grooming ", "Instant food"), Product = c("strawbery", "washing powder ", "Cat food ", "sanitary pad ", "sanitary pad ", "Noodles "), Brand = c("NO BRAND", "whe...

Shiny - observeEvent appears without click

Image
Shiny - observeEvent appears without click I would like to develop an application with two buttons : 1. Calculate 2. Refresh When I click on the button "Calculate", a second button appears. When I click on the second button, a sentence appears : "Le resultat est...". The button refresh clean the web page. Now the page is clean and only the two initial buttons appears : Calculate and Refresh. If i click another time on the button Calculate, the sentence "Le resultat est..." appears without click on the second button. Question : How can i do obtain the sentence "Le resultat est..." only after a click on the second button ? Below my code : library(shiny) data_Modele <- deval_Shiny ui <- fluidPage( actionButton("runif", "Uniform"), actionButton("reset", "Clear"), uiOutput("plot") ) server <- function(input, output){ v <- reactiveValues(data = NULL) observeEvent(input$runif, { ...

Shiny selecting ranges and numeric variable (as inputs) with leaflet

Shiny selecting ranges and numeric variable (as inputs) with leaflet On shiny, I would like to show a list of numerical variables and a slide bar so that a user could choose a numerical variable and a range. Then, observations below that number would show up as green, and observations between that range would be orange, and observations above that range would be red. The codes below work fine before I put them into shiny. But my shiny codes don't work and all observations are red. library(Rcpp) library(ggmap) library(htmlwidgets) library(leaflet) crime2 <- crime[1:50,] getColor <- function(crime2) { sapply(crime2$hour, function(hour) { if(hour< 1) { "green" } else if(hour <= 1) { "orange" } else { "red" } }) } icons <- awesomeIcons( icon = 'ios-close', iconColor = 'black', library = 'ion', markerColor = getColor(crime2) ) leaflet(crime2) %>% addTiles() %>% addAwesomeMarkers(~lon, ~...