R Shiny Summary Statistics and Boxplot












0















I'm very new to R and i need some help on getting an output for summary statistics and boxplot from a csv file. I tried the following ui.R and server.R file but it had an error message of not being able to find the csv file for the output. But i did reference the data to be read in the ui.R file.



Appreciate any advice or help on this as i'm really lost at why the error is happening. Thanks.



data <-read.csv("sample_finaldata.csv", stringsAsFactors = FALSE)


ui.R



library(shiny)
library(ggplot2)
library(dplyr)

data <-read.csv("sample_finaldata.csv", stringsAsFactors = FALSE)

shinyUI(fluidPage(
titlePanel("Anime Selection"),
sidebarLayout(
sidebarPanel(
selectInput("var",label="Choose a variable",choice=c("user_days_spent_watching"=1,
"score"=2,
"age"=3,
"user_days"=4,
"stats_mean_score"=5,
"user_days"=6
), selectize=FALSE)),
mainPanel(
h2("Summary of the variable"),
verbatimTextOutput("sum"),
plotOutput("box")
)
))
)


server.R



library(shiny)
library(datasets)

shinyServer(function(input,output){

output$sum <- renderPrint({

summary(data[,as.numeric(input$var)])
})

output$box <- renderPlot({

x<-summary(data[,as.numeric(input$var)])
boxplot(x,col="sky blue",border="purple",main=names(data[as.numeric(input$var)]))
})
}
)









share|improve this question



























    0















    I'm very new to R and i need some help on getting an output for summary statistics and boxplot from a csv file. I tried the following ui.R and server.R file but it had an error message of not being able to find the csv file for the output. But i did reference the data to be read in the ui.R file.



    Appreciate any advice or help on this as i'm really lost at why the error is happening. Thanks.



    data <-read.csv("sample_finaldata.csv", stringsAsFactors = FALSE)


    ui.R



    library(shiny)
    library(ggplot2)
    library(dplyr)

    data <-read.csv("sample_finaldata.csv", stringsAsFactors = FALSE)

    shinyUI(fluidPage(
    titlePanel("Anime Selection"),
    sidebarLayout(
    sidebarPanel(
    selectInput("var",label="Choose a variable",choice=c("user_days_spent_watching"=1,
    "score"=2,
    "age"=3,
    "user_days"=4,
    "stats_mean_score"=5,
    "user_days"=6
    ), selectize=FALSE)),
    mainPanel(
    h2("Summary of the variable"),
    verbatimTextOutput("sum"),
    plotOutput("box")
    )
    ))
    )


    server.R



    library(shiny)
    library(datasets)

    shinyServer(function(input,output){

    output$sum <- renderPrint({

    summary(data[,as.numeric(input$var)])
    })

    output$box <- renderPlot({

    x<-summary(data[,as.numeric(input$var)])
    boxplot(x,col="sky blue",border="purple",main=names(data[as.numeric(input$var)]))
    })
    }
    )









    share|improve this question

























      0












      0








      0








      I'm very new to R and i need some help on getting an output for summary statistics and boxplot from a csv file. I tried the following ui.R and server.R file but it had an error message of not being able to find the csv file for the output. But i did reference the data to be read in the ui.R file.



      Appreciate any advice or help on this as i'm really lost at why the error is happening. Thanks.



      data <-read.csv("sample_finaldata.csv", stringsAsFactors = FALSE)


      ui.R



      library(shiny)
      library(ggplot2)
      library(dplyr)

      data <-read.csv("sample_finaldata.csv", stringsAsFactors = FALSE)

      shinyUI(fluidPage(
      titlePanel("Anime Selection"),
      sidebarLayout(
      sidebarPanel(
      selectInput("var",label="Choose a variable",choice=c("user_days_spent_watching"=1,
      "score"=2,
      "age"=3,
      "user_days"=4,
      "stats_mean_score"=5,
      "user_days"=6
      ), selectize=FALSE)),
      mainPanel(
      h2("Summary of the variable"),
      verbatimTextOutput("sum"),
      plotOutput("box")
      )
      ))
      )


      server.R



      library(shiny)
      library(datasets)

      shinyServer(function(input,output){

      output$sum <- renderPrint({

      summary(data[,as.numeric(input$var)])
      })

      output$box <- renderPlot({

      x<-summary(data[,as.numeric(input$var)])
      boxplot(x,col="sky blue",border="purple",main=names(data[as.numeric(input$var)]))
      })
      }
      )









      share|improve this question














      I'm very new to R and i need some help on getting an output for summary statistics and boxplot from a csv file. I tried the following ui.R and server.R file but it had an error message of not being able to find the csv file for the output. But i did reference the data to be read in the ui.R file.



      Appreciate any advice or help on this as i'm really lost at why the error is happening. Thanks.



      data <-read.csv("sample_finaldata.csv", stringsAsFactors = FALSE)


      ui.R



      library(shiny)
      library(ggplot2)
      library(dplyr)

      data <-read.csv("sample_finaldata.csv", stringsAsFactors = FALSE)

      shinyUI(fluidPage(
      titlePanel("Anime Selection"),
      sidebarLayout(
      sidebarPanel(
      selectInput("var",label="Choose a variable",choice=c("user_days_spent_watching"=1,
      "score"=2,
      "age"=3,
      "user_days"=4,
      "stats_mean_score"=5,
      "user_days"=6
      ), selectize=FALSE)),
      mainPanel(
      h2("Summary of the variable"),
      verbatimTextOutput("sum"),
      plotOutput("box")
      )
      ))
      )


      server.R



      library(shiny)
      library(datasets)

      shinyServer(function(input,output){

      output$sum <- renderPrint({

      summary(data[,as.numeric(input$var)])
      })

      output$box <- renderPlot({

      x<-summary(data[,as.numeric(input$var)])
      boxplot(x,col="sky blue",border="purple",main=names(data[as.numeric(input$var)]))
      })
      }
      )






      r shiny statistics boxplot






      share|improve this question













      share|improve this question











      share|improve this question




      share|improve this question










      asked Nov 15 '18 at 9:04









      SvendSvend

      1




      1
























          1 Answer
          1






          active

          oldest

          votes


















          1














          You should put the data <-read.csv("sample_finaldata.csv", stringsAsFactors = FALSE) inside the server.R. (And also make sure that the file exists in the working directory)






          share|improve this answer























            Your Answer






            StackExchange.ifUsing("editor", function () {
            StackExchange.using("externalEditor", function () {
            StackExchange.using("snippets", function () {
            StackExchange.snippets.init();
            });
            });
            }, "code-snippets");

            StackExchange.ready(function() {
            var channelOptions = {
            tags: "".split(" "),
            id: "1"
            };
            initTagRenderer("".split(" "), "".split(" "), channelOptions);

            StackExchange.using("externalEditor", function() {
            // Have to fire editor after snippets, if snippets enabled
            if (StackExchange.settings.snippets.snippetsEnabled) {
            StackExchange.using("snippets", function() {
            createEditor();
            });
            }
            else {
            createEditor();
            }
            });

            function createEditor() {
            StackExchange.prepareEditor({
            heartbeatType: 'answer',
            autoActivateHeartbeat: false,
            convertImagesToLinks: true,
            noModals: true,
            showLowRepImageUploadWarning: true,
            reputationToPostImages: 10,
            bindNavPrevention: true,
            postfix: "",
            imageUploader: {
            brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
            contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
            allowUrls: true
            },
            onDemand: true,
            discardSelector: ".discard-answer"
            ,immediatelyShowMarkdownHelp:true
            });


            }
            });














            draft saved

            draft discarded


















            StackExchange.ready(
            function () {
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53315760%2fr-shiny-summary-statistics-and-boxplot%23new-answer', 'question_page');
            }
            );

            Post as a guest















            Required, but never shown

























            1 Answer
            1






            active

            oldest

            votes








            1 Answer
            1






            active

            oldest

            votes









            active

            oldest

            votes






            active

            oldest

            votes









            1














            You should put the data <-read.csv("sample_finaldata.csv", stringsAsFactors = FALSE) inside the server.R. (And also make sure that the file exists in the working directory)






            share|improve this answer




























              1














              You should put the data <-read.csv("sample_finaldata.csv", stringsAsFactors = FALSE) inside the server.R. (And also make sure that the file exists in the working directory)






              share|improve this answer


























                1












                1








                1







                You should put the data <-read.csv("sample_finaldata.csv", stringsAsFactors = FALSE) inside the server.R. (And also make sure that the file exists in the working directory)






                share|improve this answer













                You should put the data <-read.csv("sample_finaldata.csv", stringsAsFactors = FALSE) inside the server.R. (And also make sure that the file exists in the working directory)







                share|improve this answer












                share|improve this answer



                share|improve this answer










                answered Nov 15 '18 at 9:11









                annhakannhak

                1966




                1966
































                    draft saved

                    draft discarded




















































                    Thanks for contributing an answer to Stack Overflow!


                    • Please be sure to answer the question. Provide details and share your research!

                    But avoid



                    • Asking for help, clarification, or responding to other answers.

                    • Making statements based on opinion; back them up with references or personal experience.


                    To learn more, see our tips on writing great answers.




                    draft saved


                    draft discarded














                    StackExchange.ready(
                    function () {
                    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53315760%2fr-shiny-summary-statistics-and-boxplot%23new-answer', 'question_page');
                    }
                    );

                    Post as a guest















                    Required, but never shown





















































                    Required, but never shown














                    Required, but never shown












                    Required, but never shown







                    Required, but never shown

































                    Required, but never shown














                    Required, but never shown












                    Required, but never shown







                    Required, but never shown







                    Popular posts from this blog

                    Florida Star v. B. J. F.

                    Error while running script in elastic search , gateway timeout

                    Adding quotations to stringified JSON object values