I have deployed an application on ShinyApps, but my application has an extra header when deployed.
The header looks like this:
However, I would like to remove this header when the application is deployed. Is it possible to do this? I am using a sample shiny web application from the tutorials.
server.R:
library(shiny)
# Rely on the 'WorldPhones' dataset in the datasets
# package (which generally comes preloaded).
library(datasets)
# Define a server for the Shiny app
shinyServer(function(input, output) {
# Fill in the spot we created for a plot
output$phonePlot <- renderPlot({
# Render a barplot
barplot(WorldPhones[,input$region]*1000,
main=input$region,
ylab="Number of Telephones",
xlab="Year")
})
})
ui.R:
library(shiny)
# Rely on the 'WorldPhones' dataset in the datasets
# package (which generally comes preloaded).
library(datasets)
# Define the overall UI
shinyUI(
# Use a fluid Bootstrap layout
fluidPage(
# Give the page a title
titlePanel("Telephones by region"),
# Generate a row with a sidebar
sidebarLayout(
# Define the sidebar with one input
sidebarPanel(
selectInput("region", "Region:",
choices=colnames(WorldPhones)),
hr(),
helpText("Data from AT&T (1961) The World's Telephones.")
),
# Create a spot for the barplot
mainPanel(
plotOutput("phonePlot")
)
)
)
)
You're not supposed to do that. If you use a paid version of shinyapps.io then you won't have this bar, but if you're using the free version they add it as advertising because they do need to make some money somehow.
(It is possible to remove it, but I really like RStudio and all their work so I don't want to promote ways to make them lose business, sorry...)
If you look at the different plans and pricing options, it clearly says that the free version includes their logo branding
If you want to remove it then you have to pay for it, it's added on the server side. Your other option is to set up a shiny server with Digital Ocean https://www.digitalocean.com/community/tutorials/how-to-set-up-shiny-server-on-ubuntu-14-04
Related
I am currently building a shiny app to build biological networks. To build them, you can choose between many different parameters, which i included in different selectInputs or numericInputs.
Is it possible to have some kind of info text, when hovering the mouse over those input fields? I dont want to add 3-4 sentences of text to the title of each select/numericInput.
Thanks :)
If you don't mind an extra package dependancy then you can use bsTooltip from the shinyBS package. Note that the hover tooltip sometimes doesn't show up unless you click on the input in the RStudio viewer pane, but if you run your app in your browser, the hover trigger should work:
library(shiny)
library(shinyBS)
ui <- fluidPage(
selectInput("input1", "Select input", c("choice1", "choice2")),
bsTooltip(id = "input1",
title = "Here is some text with your instructions")
)
server <- function(input, output) {
}
shinyApp(ui = ui, server = server)
I'm creating a survey in Shiny where I want the choices as represented by radio buttons to be randomly drawn. See sample code below:
library(shiny)
choices<-c("a","b","c","d","e")
x1<-sample(choices,2)
x2<-sample(choices,2)
ui<-fluidPage(
radioButtons("q1","Which do you prefer?", choices=c(x1,"No Preference"),selected=""),
radioButtons("q2","Which do you prefer?", choices=c(x2,"No Preference"),selected="")),
server <- function(input, output) {
# Not important
})
shinyApp(ui = ui, server = server)
When I run the app locally a different set of choices will be selected each time I run the app (as intended). But once I publish to shinyapps.io the choices are the same each time (as in x1 is the same each time I run the app). How can I make so that each time the app opens a new sample is taken from the choice set?
As you may know, Shiny server implements caching to improve system utilization. The problem you are having is the x1 variable is being sampled and cached between users.
The way around this problem is to sample choices into a reactiveValue and then dynamically update the radio buttons when the page loads.
Alternatively, you might try using this approach:
ui <- function(req) {
fluidPage(
x1<-sample(choices,2)
x2<-sample(choices,2)
radioButtons("q1","Which do you prefer?", choices=c(x1,"No Preference"),selected=""),
radioButtons("q2","Which do you prefer?", choices=c(x2,"No Preference"),selected=""))
...
)
}
D3partitionR has some fantastic visualisations for hierarchical and sequential data, however it seems to have a major flaw in Shiny.
The D3partitionROutput function (& renderD3partitionR) don't update the plotted object when the output object is updated.
The functions work perfectly on first execution of a graph however the plotted objects can't be reactively updated.
Does anyone know of a fix or workaround as I really like this package's visualisations?
library(shiny)
library(D3partitionR)
path_in=list(list("A","B","C","D"),list("A","B","F","G"),list("A","D"),list("A","B","END"))
value_in=c(15,29,21,34)
# Define UI for application that draws a histogram
ui <- fluidPage(
# Application title
titlePanel("Old Faithful Geyser Data"),
# Sidebar with a slider input for number of bins
sidebarLayout(
sidebarPanel(
selectInput("type_in",
"Plot type:",
choices = c('circleTreeMap', 'partitionChart', 'treeMap')
)
),
# Show a plot of the generated distribution
mainPanel(
D3partitionROutput("part_out")
)
)
)
# Define server logic required to draw a histogram
server <- function(input, output) {
output$part_out <- renderD3partitionR({
type = input$type_in
D3partitionR(data=list(path=path_in,value=value_in)
, type = type)
})
}
# Run the application
shinyApp(ui = ui, server = server)
Update:
I found a similar bug here in Rwordcloud that was resolved by modifying the "render" function in Rwordcloud.js. I looked into renderValue in D3partitionR.js and the function doesn't take an input of 'instance' (as is done in Rwordcloud.js) so it seems it doesn't know when to delete / refresh renderValue. I'm an R guy (and have no js experience) so I don't know how the renderValue function should be changed in D3partitionR.js however I'm pretty sure this is the source of the problem.. Help!
I would like to add to it a feature for uploading data. I tried conditional panels but no luck. I attach my code below. What I did was I included the simulated data before the ui part of shiny and constructed the rest of the code. Thanks
library(shiny)
dat # data
ui
ui <- fluidPage(
pageWithSidebar(
headerPanel('Correlation coefficient and scatter plots'),
sidebarPanel(
Are you looking for something like fileInput? See http://shiny.rstudio.com/gallery/upload-file.html
I am trying to display from 1 to 5 tabPanels in a navbarPage in Shiny.
I have 5 plots my code generates, but I'd like a user to be able to select how many they want to have access to -- to be displayed one plot in each tabPanel, naturally.
I've got an external configuration file (config.txt) that via source('config.txt'), I have access to a number_of_pages variable.
For example, number_of_tabPages <- 3
How would I set this up in UI.R?
The number of tabPanels can't be hardcoded at all in the UI file, since it depends on a value that is specified by a user, not using a control.
I've searched around and found that most of the approaches to this kind of thing
involve using uiOutput and renderUI functions, such as this similar problem, but I don't want any special control in the UI to do any selecting.
This is where things get tricky, when we are building the UI depending on values that may change. My brain is trying to wrap itself around the best method for doing this type of thing -- I feel like it isn't exactly in line with how Shiny wants to communicate with itself using a UI <--> server environment.
Any advice is greatly appreciated.
My UI.R is easy to create when it isn't dynamic:
fluidRow(
column(12,
"",
navbarPage("",tabPanel("First Tab",
plotOutput("plot1")),
tabPanel("Second Tab",
plotOutput("plot2")),
tabPanel("Third Tab",
plotOutput("plot3")),
tabPanel("Fourth Tab",
plotOutput("plot4")),
tabPanel("Fifth Tab",
plotOutput("plot5"))
)
)
)
)
Thanks!
If you don't need the user to change the number of tabPanel interactively, but just load varying numbers of them when the app is started you can use the do.call function in the navBarPage:
library(dplyr)
library(shiny)
library(ggvis)
#number of tabs needed
number_of_tabPages <- 10
#make a list of all the arguments you want to pass to the navbarPage function
tabs<-list()
#first element will be the title, empty in your example
tabs[[1]]=""
#add all the tabPanels to the list
for (i in 2:(number_of_tabPages+1)){
tabs[[i]]=tabPanel(paste0("Tab",i-1),plotOutput(paste0("plot",i-1)))
}
#do.call will call the navbarPage function with the arguments in the tabs list
shinyUI(fluidRow(
column(12,
"",
do.call(navbarPage,tabs)
)
)
)