डेटा देखने के और तरीके: plot और download

केस स्टडीज़: R में Shiny के साथ वेब एप्लिकेशन बनाना

Dean Attali

Shiny Consultant

डेटा plot करें

  • नए डेटासेट को एक्सप्लोर करते समय plots आम पहला कदम होते हैं

    • Plots आउटपुट होते हैं
    • UI में plot आउटपुट प्लेसहोल्डर फंक्शन:
    plotOutput("my_plot")
    
    • सर्वर में plot render फंक्शन:
  output$my_plot <- renderPlot({
      # code for a plot
  })
केस स्टडीज़: R में Shiny के साथ वेब एप्लिकेशन बनाना

डेटा download करें

  • Downloading, download बटन से सपोर्टेड है

    अध्याय 3: डेटा देखने के और तरीके — plot और download

    • किसी भी प्रकार की फ़ाइल बना सकते हैं
    • image files, text files, CSV files
केस स्टडीज़: R में Shiny के साथ वेब एप्लिकेशन बनाना

CSV फाइलें

  • Comma Separated Values

  • छोटे-मध्यम डेटासेट स्टोर करें

  • gapminder का CSV:

    country,continent,year,lifeExp,pop,gdpPercap  
    Afghanistan,Asia,1952,28.801,8425333,779.4453145  
    Afghanistan,Asia,1957,30.332,9240934,820.8530296  
    Afghanistan,Asia,1962,31.997,10267083,853.10071  
    Afghanistan,Asia,1967,34.02,11537966,836.1971382
    
  • CSV फ़ाइल बनाएँ:

write.csv(gapminder, "myfile.csv")
केस स्टडीज़: R में Shiny के साथ वेब एप्लिकेशन बनाना

Shiny में डेटा download करें

  • Download बटन को आउटपुट माना जाता है

    • UI में download बटन जोड़ें: (output फंक्शन्स जैसा)
    downloadButton(outputId = "download_data", 
                   label = "Download data")
    
    • सर्वर में download हैंडलर जोड़ें: (render फंक्शन्स जैसा)
    output$download_data <- downloadHandler(
        filename = "data.csv",
        content = function(file) {
            # Code that creates a file in the path <file>
            write.csv(gapminder, file)
        }
    )
    
केस स्टडीज़: R में Shiny के साथ वेब एप्लिकेशन बनाना

Download हैंडलर

  output$download_data <- downloadHandler(
      filename = "data.csv",
      content = function(file) {
          # code that creates a file in the path <file>
          write.csv(gapminder, file)
      }
  )
  • downloadHandler() के दो आर्ग्यूमेंट होते हैं
    • filename
      • डाउनलोड की गई फ़ाइल का नाम
    • content(file)
      • 1 आर्ग्यूमेंट वाला फंक्शन
      • डाउनलोड होने वाली फ़ाइल बनाएँ, आर्ग्यूमेंट फ़ाइल पाथ है
केस स्टडीज़: R में Shiny के साथ वेब एप्लिकेशन बनाना

अभ्यास करते हैं!

केस स्टडीज़: R में Shiny के साथ वेब एप्लिकेशन बनाना

Preparing Video For Download...