-
Notifications
You must be signed in to change notification settings - Fork 21
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
QR code for URL #3
Comments
Hi @Yang-Tang, I've just updated shinyURL to provide an easy way of capturing the URL inside the app's script. Starting from version 0.0.30, the function A possible use case is to take the URL and use it to generate a QR code which will be displayed to the user instead of the default library("shiny")
library("shinyURL")
library("qrcode")
shinyApp(
ui = fluidPage(
titlePanel("Old Faithful Geyser Data"),
sidebarLayout(
sidebarPanel(
sliderInput("bins", "Number of bins:", min = 1, max = 50, value = 30),
plotOutput("qrcode")
),
mainPanel(
plotOutput("plot")
)
)
),
server = function(input, output) {
url = shinyURL.server()
output$plot <- renderPlot({
x <- faithful[, 2]
bins <- seq(min(x), max(x), length.out = input$bins + 1)
hist(x, breaks = bins, col = 'darkgray', border = 'white')
})
qrcode = reactive( t(qrcode_gen(url(), plotQRcode = FALSE, dataOutput = TRUE)) )
nc = reactive( ncol(qrcode()) )
nr = reactive( nrow(qrcode()) )
scale = 4
output$qrcode <- renderPlot({
par(mar=c(0,0,0,0))
image(1L:nc(), 1L:nr(), qrcode(), xlim = 0.5 + c(0, nc()),
ylim = 0.5 + c(nr(), 0), axes = FALSE, xlab = "", ylab = "",
col = c("white", "black"), asp = 1)
}, width = function() scale*nc(), height = function() scale*nr())
}
) For an application in an interactive R markdown document, see the example distributed with the package. |
Thank you @aoles ! The code and documents are very useful. |
Thank you for this nice shiny package. It would be more insteresting to add an option to generate a URL QR code of current status of shiny app.
The text was updated successfully, but these errors were encountered: