aagarw30 / r-shinyapp-tutorial Goto Github PK
View Code? Open in Web Editor NEWLicense: GNU General Public License v3.0
License: GNU General Public License v3.0
I was going through your video on "Submit Button" - Example 2.
It is very helpful.
Thanks,
Madhuri
Hi abhinav,
In Fileinput_uploadmultiplefiles, When I'm running this code no output is coming.
What is your License for these tutorials?
Add a LICENSE file please
My ur.R file goes as follows:
library(shiny)
shinyUI(
fluidPage(
titlePanel(title = h4('Demonstraion of renderplot', align='center')),
sidebarLayout(
sidebarPanel(
selectInput('var', "Select the Variable", choices = c('Sepal.Length' =1 , 'sepal width' = 2, 'Petal Length' = 3 , 'Petal Width' = 4), selected = 1),
br(),
sliderInput('bins', 'Select the number of bins', min = 5, max = 25, value = 15),
br(),
radioButtons('color', 'Color of the bins', choices = c('Green', 'Red', 'Blue'), selected = 'Green'),
br(),
radioButtons('type', 'Choose the type', choices = list('png', 'pdf'), selected = 'png')
),
mainPanel(
plotOutput("myhist"),
downloadButton('down', 'Download the Plot')
)
)
)
)
and my server.R goes as follows:
shinyServer(function(input, output){
colm = reactive({
as.numeric(input$var)
})
output$myhist = renderPlot(
{
hist(iris[,colm()], breaks = seq(0,max(iris[,colm()], l= input$bins+1)),col =input$color, main ="Histogram of irish dataset", xlab = names(iris[colm()]))
}
)
output$down <- downloadHandler(
filename = function() {
paste("iris", input$var3, sep=".")
},
# content is a function with argument file. content writes the plot to the device
content = function(file) {
if(input$var3 == "png")
png(file) # open the png device
else
pdf(file) # open the pdf device
hist(colm()) # draw the plot
dev.off() # turn the device off
}
)
})
When I hit the download button, It shows like the following whereas the file name suppose to be iris.png
. Why this behaviour?
I have also tried wrapping arguments of the function, downdloadHandler
like this
output$down <- downloadHandler({
filename = function() {
paste("iris", input$var3, sep=".")
},
# content is a function with argument file. content writes the plot to the device
content = function(file) {
if(input$var3 == "png")
png(file) # open the png device
else
pdf(file) # open the pdf device
hist(colm()) # draw the plot
dev.off() # turn the device off
}
})
But this gave the error message as follows.
Error in parse(file, keep.source = FALSE, srcfile = src, encoding = enc) :
G:\R_workshop_related_NITTE\Shiny\downloadPlots/server.R:17:6: unexpected ','
16: paste("iris", input$var3, sep=".")
17: },
^
Warning: Error in sourceUTF8: Error sourcing C:\Users\Mahe\AppData\Local\Temp\RtmpIPEtpl\file29805c1e4eca
Stack trace (innermost first):
1: runApp
Error in sourceUTF8(serverR, envir = new.env(parent = globalenv())) :
Error sourcing C:\Users\Mahe\AppData\Local\Temp\RtmpIPEtpl\file29805c1e4eca
I am in windows machine Rstudio Version 1.1.442 with R 3.4.4.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.