Code Monkey home page Code Monkey logo

r-shinyapp-tutorial's People

Contributors

aagarw30 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

r-shinyapp-tutorial's Issues

No output is coming

Hi abhinav,
In Fileinput_uploadmultiplefiles, When I'm running this code no output is coming.

Downloadhandler doesnt respect the paste function.

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
      
    } 
  )
  
  
  
}) 

image

When I hit the download button, It shows like the following whereas the file name suppose to be iris.png. Why this behaviour?
image

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.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.